Skip to content

Commit

Permalink
Add installer for automatic file placement
Browse files Browse the repository at this point in the history
  • Loading branch information
hdrover committed Nov 17, 2024
1 parent a027dbc commit 74bc513
Show file tree
Hide file tree
Showing 13 changed files with 2,354 additions and 595 deletions.
137 changes: 137 additions & 0 deletions Options.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
unit Options;

interface

uses
System.SysUtils,
IniFiles,
System.RegularExpressions;

const
DLL_FILENAME = 'version.dll';
OPTIONS_FILENAME = 'drover.ini';

type
TDroverOptions = record
proxy: string;
useNekoboxProxy: boolean;
nekoboxProxy: string;
end;

TProxyValue = record
isSpecified: boolean;
prot: string;
login: string;
password: string;
host: string;
port: integer;
isHttp: boolean;
isSocks5: boolean;
isAuth: boolean;

procedure ParseFromString(url: string);
function FormatToHttpEnv: string;
function FormatToChromeProxy: string;
end;

function LoadOptions(filename: string): TDroverOptions;
function SaveOptions(filename: string; opt: TDroverOptions): boolean;

implementation

procedure TProxyValue.ParseFromString(url: string);
var
match: TMatch;
begin
isSpecified := false;
prot := '';
login := '';
password := '';
host := '';
port := 0;
isHttp := false;
isSocks5 := false;
isAuth := false;

match := TRegEx.match(Trim(url), '\A(?:([a-z\d]+)://)?(?:(.+):(.+)@)?(.+):(\d+)\z', [roIgnoreCase]);
if not match.Success then
exit;

isSpecified := true;

prot := LowerCase(Trim(match.Groups[1].Value));
if (prot = '') or (prot = 'https') then
prot := 'http';

login := Trim(match.Groups[2].Value);
password := Trim(match.Groups[3].Value);

host := Trim(match.Groups[4].Value);
port := StrToIntDef(match.Groups[5].Value, 0);

isHttp := (prot = 'http');
isSocks5 := (prot = 'socks5');
isAuth := (login <> '') and (password <> '');
end;

function TProxyValue.FormatToHttpEnv: string;
begin
if not isSpecified then
exit('');

result := 'http://';
if isAuth then
result := result + login + ':' + password + '@';
result := result + host + ':' + IntToStr(port);
end;

function TProxyValue.FormatToChromeProxy: string;
begin
if isSpecified then
result := Format('%s://%s:%d', [prot, host, port])
else
result := '';
end;

function LoadOptions(filename: string): TDroverOptions;
var
f: TIniFile;
begin
result := Default (TDroverOptions);

try
f := TIniFile.Create(filename);
try
with f do
begin
result.proxy := ReadString('drover', 'proxy', '');
result.useNekoboxProxy := ReadBool('drover', 'use-nekobox-proxy', false);
result.nekoboxProxy := ReadString('drover', 'nekobox-proxy', '127.0.0.1:2080');
end;
finally
f.Free;
end;
except
end;
end;

function SaveOptions(filename: string; opt: TDroverOptions): boolean;
var
f: TextFile;
begin
try
AssignFile(f, filename);
try
Rewrite(f);
WriteLn(f, '[drover]');
WriteLn(f, Trim('proxy = ' + opt.proxy));
finally
CloseFile(f);
end;
result := true;
except
result := false;
end;
end;

end.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Discord Drover
# Discord Drover (Proxy Settings for Discord)

Discord Drover is a program that forces the Discord application for Windows to use a specified proxy server (HTTP or SOCKS5) for TCP connections (chat, updates). This may be necessary because the original Discord application lacks proxy settings, and the global system proxy is also not used. Additionally, the program slightly interferes with Discord's outgoing UDP traffic, which helps bypass some local restrictions on voice chats.

The program works locally at the specific process level (without drivers) and does not affect the operating system globally. This approach serves as an alternative to using a global VPN (such as TUN interfaces and others).

## Installation

To use Discord Drover, copy the `version.dll` and `drover.ini` files into the folder containing the `Discord.exe` file (not `Update.exe`). The proxy itself is specified in the `drover.ini` file under the `proxy` parameter.
### Automatic Installation

For an easier setup, use the included installer `drover.exe`. Run the program and fill in the proxy settings, then click **Install** to automatically place the necessary files in the correct folder.

To uninstall the program and remove all associated files, run `drover.exe` again and click **Uninstall**.

### Manual Installation

If you prefer manual installation, copy the `version.dll` and `drover.ini` files into the folder containing the `Discord.exe` file (not `Update.exe`). The proxy itself is specified in the `drover.ini` file under the `proxy` parameter.

### Example `drover.ini` Configuration:

Expand Down
Loading

0 comments on commit 74bc513

Please sign in to comment.