ret = MyMalloc(sizeof(OPM_CONFIG_T));
ret->vars = MyMalloc(sizeof(void *) * num);
+
+ /* Set default config items. This in the future would be much better
+ if it could set realistic defaults for each individual config item.
+
+ OPM_TYPE_INT = 0
+ OPM_TYPE_STRING = ""
+ OPM_TYPE_ADDRESS = 0.0.0.0
+
+ */
+
for(i = 0; i < num; i++)
- ret->vars[i] = NULL;
-
+ {
+ switch(libopm_config_gettype(i))
+ {
+ case OPM_TYPE_INT:
+ ret->vars[i] = MyMalloc(sizeof(int));
+ *(int *) ret->vars[i] = 0;
+ break;
+ case OPM_TYPE_STRING:
+ (char *) ret->vars[i] = strdup("");
+ break;
+ case OPM_TYPE_ADDRESS:
+ (opm_sockaddr *) ret->vars[i] = MyMalloc(sizeof(opm_sockaddr));
+ memset((opm_sockaddr *) ret->vars[i], 0, sizeof(opm_sockaddr));
+ break;
+ default:
+ ret->vars[i] = NULL;
+ }
+ }
return ret;
}
*/
static OPM_PROTOCOL_T OPM_PROTOCOLS[] = {
- {OPM_TYPE_HTTP, libopm_proxy_http_write, NULL},
- {OPM_TYPE_SOCKS4, libopm_proxy_socks4_write, NULL},
- {OPM_TYPE_SOCKS5, libopm_proxy_socks5_write, NULL},
- {OPM_TYPE_WINGATE, libopm_proxy_wingate_write, NULL},
- {OPM_TYPE_ROUTER, libopm_proxy_router_write, NULL}
+ {OPM_TYPE_HTTP, libopm_proxy_http_write, NULL, NULL},
+ {OPM_TYPE_SOCKS4, libopm_proxy_socks4_write, NULL, NULL},
+ {OPM_TYPE_SOCKS5, libopm_proxy_socks5_write, NULL, NULL},
+ {OPM_TYPE_WINGATE, libopm_proxy_wingate_write, NULL, NULL},
+ {OPM_TYPE_ROUTER, libopm_proxy_router_write, NULL, NULL}
};
{
OPM_PROTOCOL_T *type; /* Protocol type */
unsigned short int port; /* Port to connect on */
+
};
struct _OPM_PROTOCOL
int type; /* Protocol type */
OPM_PROXYWRITE_T *write_function; /* Write function handler for this protocol */
OPM_PROXYREAD_T *read_function; /* Read function handler for this protocol */
+
+ char *format; /* Custom formatting if this is a custom protocol
+ this is only valid if type == OPM_TYPE_CUSTOM */
};
#endif /* LIBOPM_H */
#define OPM_CONFIG_TIMEOUT 7
/* Configuration Variable Types */
-#define OPM_TYPE_INT 1
-#define OPM_TYPE_STRING 2
-#define OPM_TYPE_ADDRESS 3
+#define OPM_TYPE_INT 1
+#define OPM_TYPE_STRING 2
+#define OPM_TYPE_ADDRESS 3
/* Protocols */
-#define OPM_TYPE_HTTP 1
-#define OPM_TYPE_SOCKS4 2
-#define OPM_TYPE_SOCKS5 3
-#define OPM_TYPE_WINGATE 4
-#define OPM_TYPE_ROUTER 5
+#define OPM_TYPE_CUSTOM 1
+#define OPM_TYPE_HTTP 2
+#define OPM_TYPE_SOCKS4 3
+#define OPM_TYPE_SOCKS5 4
+#define OPM_TYPE_WINGATE 5
+#define OPM_TYPE_ROUTER 6
/* States */
-#define OPM_STATE_UNESTABLISHED 0
-#define OPM_STATE_ESTABLISHED 1
-#define OPM_STATE_NEGSENT 2
-#define OPM_STATE_CLOSED 3
+#define OPM_STATE_UNESTABLISHED 1
+#define OPM_STATE_ESTABLISHED 2
+#define OPM_STATE_NEGSENT 3
+#define OPM_STATE_CLOSED 4
/* Callbacks -- If more callback types are added,
- REMOTECBLEN and SCANCBLEN will need to be changed
- in libopm.h accordingly */
-
-#define OPM_CALLBACK_OPENPROXY 0 /* An open proxy has been found REMOTE/SCANNER */
-#define OPM_CALLBACK_NEGFAIL 1 /* Negotiation to a proxy has failed REMOTE/SCANNER */
-#define OPM_CALLBACK_END 2 /* A scan has ended REMOTE/SCANNER */
-#define OPM_CALLBACK_ERROR 3 /* An unrecoverable error has occured */
-#define OPM_CALLBACK_TIMEOUT 4 /* Specific scan (protocol) on host has timed out */
+ CBLEN will need to be changed in libopm.h accordingly */
+
+#define OPM_CALLBACK_OPENPROXY 0 /* An open proxy has been found REMOTE/SCANNER */
+#define OPM_CALLBACK_NEGFAIL 1 /* Negotiation to a proxy has failed REMOTE/SCANNER */
+#define OPM_CALLBACK_END 2 /* A scan has ended REMOTE/SCANNER */
+#define OPM_CALLBACK_ERROR 3 /* An unrecoverable error has occured */
+#define OPM_CALLBACK_TIMEOUT 4 /* Specific scan (protocol) on host has timed out */
#endif /* OPM_TYPES_H */