1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-20 02:30:40 +03:00
SoftEtherVPN/src/Mayaqua/Proxy.h
Davide Beatrici b8f58a2f94 Move generic proxy stuff from Cedar to Mayaqua
This commit moves the generic (not related to our protocol) proxy stuff from Cedar to Mayaqua, in dedicated files.

The functions are refactored so that they all have the same arguments and follow the same logic.

Dedicated error codes are added, in order to indicate clearly why the function(s) failed.
2019-10-30 01:39:04 +01:00

46 lines
1.2 KiB
C

#ifndef PROXY_H
#define PROXY_H
#define PROXY_CONNECTION_TIMEOUT (4 * 1000)
#define PROXY_MAX_USERNAME_LEN 255
#define PROXY_MAX_PASSWORD_LEN 255
#define PROXY_ERROR_SUCCESS 0
#define PROXY_ERROR_GENERIC 1
#define PROXY_ERROR_PARAMETER 2
#define PROXY_ERROR_CANCELED 3
#define PROXY_ERROR_CONNECTION 4
#define PROXY_ERROR_DISCONNECTED 5
#define PROXY_ERROR_VERSION 6
#define PROXY_ERROR_AUTHENTICATION 7
#define PROXY_ERROR_TARGET 8
struct PROXY_PARAM_IN
{
char Hostname[MAX_HOST_NAME_LEN + 1];
USHORT Port;
char TargetHostname[MAX_HOST_NAME_LEN + 1];
USHORT TargetPort;
char Username[PROXY_MAX_USERNAME_LEN + 1];
char Password[PROXY_MAX_PASSWORD_LEN + 1];
UINT Timeout;
char HttpCustomHeader[HTTP_CUSTOM_HEADER_MAX_SIZE + 1];
char HttpUserAgent[HTTP_HEADER_USER_AGENT_MAX_SIZE + 1];
#ifdef OS_WIN32
void *Hwnd;
#endif
};
struct PROXY_PARAM_OUT
{
SOCK *Sock;
IP ResolvedIp;
};
UINT ProxyHttpConnect(PROXY_PARAM_OUT *out, PROXY_PARAM_IN *in, volatile bool *cancel_flag);
UINT ProxySocks5Connect(PROXY_PARAM_OUT *out, PROXY_PARAM_IN *in, volatile bool *cancel_flag);
UINT ProxySocks4Connect(PROXY_PARAM_OUT *out, PROXY_PARAM_IN *in, volatile bool *cancel_flag);
#endif