(libT) add proxy port arg as requested by BentMyWookie
This commit is contained in:
parent
4813647346
commit
7974a1e50a
|
@ -286,6 +286,7 @@ main( int argc, char ** argv )
|
|||
FALSE, "fnord", "potzrebie",
|
||||
TR_DEFAULT_PROXY_ENABLED,
|
||||
TR_DEFAULT_PROXY,
|
||||
TR_DEFAULT_PROXY_PORT,
|
||||
TR_DEFAULT_PROXY_TYPE,
|
||||
TR_DEFAULT_PROXY_AUTH_ENABLED,
|
||||
TR_DEFAULT_PROXY_USERNAME,
|
||||
|
|
|
@ -193,6 +193,7 @@ session_init( const char * configDir, const char * downloadDir,
|
|||
TRUE, rpcPort, acl, authRequired, username, password,
|
||||
TR_DEFAULT_PROXY_ENABLED,
|
||||
TR_DEFAULT_PROXY,
|
||||
TR_DEFAULT_PROXY_PORT,
|
||||
TR_DEFAULT_PROXY_TYPE,
|
||||
TR_DEFAULT_PROXY_AUTH_ENABLED,
|
||||
TR_DEFAULT_PROXY_USERNAME,
|
||||
|
|
|
@ -433,6 +433,7 @@ main( int argc, char ** argv )
|
|||
pref_string_get( PREF_KEY_RPC_PASSWORD ),
|
||||
pref_flag_get( PREF_KEY_PROXY_SERVER_ENABLED ),
|
||||
pref_string_get( PREF_KEY_PROXY_SERVER ),
|
||||
pref_int_get( PREF_KEY_PROXY_PORT ),
|
||||
pref_int_get( PREF_KEY_PROXY_TYPE ),
|
||||
pref_flag_get( PREF_KEY_PROXY_AUTH_ENABLED ),
|
||||
pref_string_get( PREF_KEY_PROXY_USERNAME ),
|
||||
|
|
|
@ -78,9 +78,10 @@ tr_prefs_init_global( void )
|
|||
pref_int_set_default ( PREF_KEY_MAIN_WINDOW_Y, 50 );
|
||||
|
||||
pref_string_set_default ( PREF_KEY_PROXY_SERVER, "" );
|
||||
pref_int_set_default ( PREF_KEY_PROXY_TYPE, TR_PROXY_HTTP );
|
||||
pref_flag_set_default ( PREF_KEY_PROXY_SERVER_ENABLED, FALSE );
|
||||
pref_flag_set_default ( PREF_KEY_PROXY_AUTH_ENABLED, FALSE );
|
||||
pref_int_set_default ( PREF_KEY_PROXY_PORT, TR_DEFAULT_PROXY_PORT );
|
||||
pref_int_set_default ( PREF_KEY_PROXY_TYPE, TR_DEFAULT_PROXY_TYPE );
|
||||
pref_flag_set_default ( PREF_KEY_PROXY_SERVER_ENABLED, TR_DEFAULT_PROXY_ENABLED );
|
||||
pref_flag_set_default ( PREF_KEY_PROXY_AUTH_ENABLED, TR_DEFAULT_PROXY_AUTH_ENABLED );
|
||||
pref_string_set_default ( PREF_KEY_PROXY_USERNAME, "" );
|
||||
pref_string_set_default ( PREF_KEY_PROXY_PASSWORD, "" );
|
||||
|
||||
|
@ -964,12 +965,12 @@ onProxyTypeChanged( GtkComboBox * w, gpointer gpage )
|
|||
}
|
||||
|
||||
static GtkWidget*
|
||||
networkPage( GObject * core )
|
||||
trackerPage( GObject * core )
|
||||
{
|
||||
int row = 0;
|
||||
const char * s;
|
||||
GtkWidget * t;
|
||||
GtkWidget * w, * w2;
|
||||
GtkWidget * w;
|
||||
GtkTreeModel * m;
|
||||
GtkCellRenderer * r;
|
||||
struct ProxyPage * page = tr_new0( struct ProxyPage, 1 );
|
||||
|
@ -977,30 +978,6 @@ networkPage( GObject * core )
|
|||
page->core = TR_CORE( core );
|
||||
|
||||
t = hig_workarea_create( );
|
||||
hig_workarea_add_section_title (t, &row, _( "Router" ) );
|
||||
|
||||
s = _("Use UPnP or NAT-PMP port _forwarding from my router" );
|
||||
w = new_check_button( s, PREF_KEY_PORT_FORWARDING, core );
|
||||
hig_workarea_add_wide_control( t, &row, w );
|
||||
|
||||
hig_workarea_add_section_divider( t, &row );
|
||||
hig_workarea_add_section_title (t, &row, _("Bandwidth"));
|
||||
|
||||
s = _("Limit _download speed (KB/s):");
|
||||
w = new_check_button( s, PREF_KEY_DL_LIMIT_ENABLED, core );
|
||||
w2 = new_spin_button( PREF_KEY_DL_LIMIT, core, 0, INT_MAX, 5 );
|
||||
gtk_widget_set_sensitive( GTK_WIDGET(w2), pref_flag_get( PREF_KEY_DL_LIMIT_ENABLED ) );
|
||||
g_signal_connect( w, "toggled", G_CALLBACK(target_cb), w2 );
|
||||
hig_workarea_add_row_w( t, &row, w, w2, NULL );
|
||||
|
||||
s = _("Limit _upload speed (KB/s):");
|
||||
w = new_check_button( s, PREF_KEY_UL_LIMIT_ENABLED, core );
|
||||
w2 = new_spin_button( PREF_KEY_UL_LIMIT, core, 0, INT_MAX, 5 );
|
||||
gtk_widget_set_sensitive( GTK_WIDGET(w2), pref_flag_get( PREF_KEY_UL_LIMIT_ENABLED ) );
|
||||
g_signal_connect( w, "toggled", G_CALLBACK(target_cb), w2 );
|
||||
hig_workarea_add_row_w( t, &row, w, w2, NULL );
|
||||
|
||||
hig_workarea_add_section_divider( t, &row );
|
||||
hig_workarea_add_section_title (t, &row, _( "Tracker Proxy" ) );
|
||||
|
||||
s = _( "Connect to tracker with HTTP proxy" );
|
||||
|
@ -1014,6 +991,11 @@ networkPage( GObject * core )
|
|||
w = hig_workarea_add_row( t, &row, s, w, NULL );
|
||||
page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
|
||||
|
||||
w = new_spin_button( PREF_KEY_PROXY_PORT, core, 0, 65536, 1 );
|
||||
page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
|
||||
w = hig_workarea_add_row( t, &row, _( "Proxy port:" ), w, NULL );
|
||||
page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
|
||||
|
||||
s = _( "Proxy type:" );
|
||||
m = proxyTypeModelNew( );
|
||||
w = gtk_combo_box_new_with_model( m );
|
||||
|
@ -1053,6 +1035,42 @@ networkPage( GObject * core )
|
|||
return t;
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
networkPage( GObject * core )
|
||||
{
|
||||
int row = 0;
|
||||
const char * s;
|
||||
GtkWidget * t;
|
||||
GtkWidget * w, * w2;
|
||||
|
||||
t = hig_workarea_create( );
|
||||
hig_workarea_add_section_title (t, &row, _( "Router" ) );
|
||||
|
||||
s = _("Use UPnP or NAT-PMP port _forwarding from my router" );
|
||||
w = new_check_button( s, PREF_KEY_PORT_FORWARDING, core );
|
||||
hig_workarea_add_wide_control( t, &row, w );
|
||||
|
||||
hig_workarea_add_section_divider( t, &row );
|
||||
hig_workarea_add_section_title (t, &row, _("Bandwidth"));
|
||||
|
||||
s = _("Limit _download speed (KB/s):");
|
||||
w = new_check_button( s, PREF_KEY_DL_LIMIT_ENABLED, core );
|
||||
w2 = new_spin_button( PREF_KEY_DL_LIMIT, core, 0, INT_MAX, 5 );
|
||||
gtk_widget_set_sensitive( GTK_WIDGET(w2), pref_flag_get( PREF_KEY_DL_LIMIT_ENABLED ) );
|
||||
g_signal_connect( w, "toggled", G_CALLBACK(target_cb), w2 );
|
||||
hig_workarea_add_row_w( t, &row, w, w2, NULL );
|
||||
|
||||
s = _("Limit _upload speed (KB/s):");
|
||||
w = new_check_button( s, PREF_KEY_UL_LIMIT_ENABLED, core );
|
||||
w2 = new_spin_button( PREF_KEY_UL_LIMIT, core, 0, INT_MAX, 5 );
|
||||
gtk_widget_set_sensitive( GTK_WIDGET(w2), pref_flag_get( PREF_KEY_UL_LIMIT_ENABLED ) );
|
||||
g_signal_connect( w, "toggled", G_CALLBACK(target_cb), w2 );
|
||||
hig_workarea_add_row_w( t, &row, w, w2, NULL );
|
||||
|
||||
hig_workarea_finish( t, &row );
|
||||
return t;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
tr_prefs_dialog_new( GObject * core, GtkWindow * parent )
|
||||
{
|
||||
|
@ -1082,6 +1100,9 @@ tr_prefs_dialog_new( GObject * core, GtkWindow * parent )
|
|||
gtk_notebook_append_page( GTK_NOTEBOOK( n ),
|
||||
peerPage( core, alive ),
|
||||
gtk_label_new (_("Peers")) );
|
||||
gtk_notebook_append_page( GTK_NOTEBOOK( n ),
|
||||
trackerPage( core ),
|
||||
gtk_label_new (_("Trackers")) );
|
||||
gtk_notebook_append_page( GTK_NOTEBOOK( n ),
|
||||
networkPage( core ),
|
||||
gtk_label_new (_("Network")) );
|
||||
|
|
|
@ -61,6 +61,7 @@ GtkWidget * tr_prefs_dialog_new( GObject * core, GtkWindow * parent );
|
|||
#define PREF_KEY_RPC_PASSWORD "rpc-password"
|
||||
#define PREF_KEY_RPC_USERNAME "rpc-username"
|
||||
#define PREF_KEY_PROXY_SERVER "proxy-server"
|
||||
#define PREF_KEY_PROXY_PORT "proxy-port"
|
||||
#define PREF_KEY_PROXY_SERVER_ENABLED "proxy-server-enabled"
|
||||
#define PREF_KEY_PROXY_TYPE "proxy-type"
|
||||
#define PREF_KEY_PROXY_AUTH_ENABLED "proxy-authentication-required"
|
||||
|
|
|
@ -189,7 +189,7 @@ tr_sessionInitFull( const char * configDir,
|
|||
const char * downloadDir,
|
||||
int isPexEnabled,
|
||||
int isPortForwardingEnabled,
|
||||
int publicPort,
|
||||
int publicPort,
|
||||
int encryptionMode,
|
||||
int isUploadLimitEnabled,
|
||||
int uploadLimit,
|
||||
|
@ -208,6 +208,7 @@ tr_sessionInitFull( const char * configDir,
|
|||
const char * rpcPassword,
|
||||
int proxyIsEnabled,
|
||||
const char * proxy,
|
||||
int proxyPort,
|
||||
tr_proxy_type proxyType,
|
||||
int proxyAuthIsEnabled,
|
||||
const char * proxyUsername,
|
||||
|
@ -236,6 +237,7 @@ tr_sessionInitFull( const char * configDir,
|
|||
h->downloadDir = tr_strdup( downloadDir );
|
||||
h->isProxyEnabled = proxyIsEnabled ? 1 : 0;
|
||||
h->proxy = tr_strdup( proxy );
|
||||
h->proxyPort = proxyPort;
|
||||
h->proxyType = proxyType;
|
||||
h->isProxyAuthEnabled = proxyAuthIsEnabled ? 1 : 0;
|
||||
h->proxyUsername = tr_strdup( proxyUsername );
|
||||
|
@ -316,6 +318,7 @@ tr_sessionInit( const char * configDir,
|
|||
"potzrebie",
|
||||
TR_DEFAULT_PROXY_ENABLED,
|
||||
TR_DEFAULT_PROXY,
|
||||
TR_DEFAULT_PROXY_PORT,
|
||||
TR_DEFAULT_PROXY_TYPE,
|
||||
TR_DEFAULT_PROXY_AUTH_ENABLED,
|
||||
TR_DEFAULT_PROXY_USERNAME,
|
||||
|
@ -976,6 +979,11 @@ tr_sessionGetProxy( const tr_session * session )
|
|||
{
|
||||
return session->proxy;
|
||||
}
|
||||
int
|
||||
tr_sessionGetProxyPort( const tr_session * session )
|
||||
{
|
||||
return session->proxyPort;
|
||||
}
|
||||
void
|
||||
tr_sessionSetProxy( tr_session * session, const char * proxy )
|
||||
{
|
||||
|
@ -985,6 +993,11 @@ tr_sessionSetProxy( tr_session * session, const char * proxy )
|
|||
session->proxy = tr_strdup( proxy );
|
||||
}
|
||||
}
|
||||
void
|
||||
tr_sessionSetProxyPort( tr_session * session, int port )
|
||||
{
|
||||
session->proxyPort = port;
|
||||
}
|
||||
int
|
||||
tr_sessionIsProxyAuthEnabled( const tr_session * session )
|
||||
{
|
||||
|
|
|
@ -62,6 +62,7 @@ struct tr_handle
|
|||
|
||||
struct tr_event_handle * events;
|
||||
|
||||
int proxyPort;
|
||||
int peerSocketTOS;
|
||||
|
||||
int torrentCount;
|
||||
|
|
|
@ -133,6 +133,8 @@ tr_proxy_type;
|
|||
/** @see tr_sessionInitFull */
|
||||
#define TR_DEFAULT_PROXY NULL
|
||||
/** @see tr_sessionInitFull */
|
||||
#define TR_DEFAULT_PROXY_PORT 80
|
||||
/** @see tr_sessionInitFull */
|
||||
#define TR_DEFAULT_PROXY_TYPE TR_PROXY_HTTP
|
||||
/** @see tr_sessionInitFull */
|
||||
#define TR_DEFAULT_PROXY_AUTH_ENABLED 0
|
||||
|
@ -261,6 +263,7 @@ tr_handle * tr_sessionInitFull( const char * configDir,
|
|||
const char * rpcPassword,
|
||||
int proxyIsEnabled,
|
||||
const char * proxy,
|
||||
int proxyPort,
|
||||
tr_proxy_type proxyType,
|
||||
int proxyAuthIsEnabled,
|
||||
const char * proxyUsername,
|
||||
|
@ -427,11 +430,13 @@ void tr_sessionSetRPCCallback( tr_session * handle,
|
|||
int tr_sessionIsProxyEnabled ( const tr_session * );
|
||||
int tr_sessionIsProxyAuthEnabled ( const tr_session * );
|
||||
const char* tr_sessionGetProxy ( const tr_session * );
|
||||
int tr_sessionGetProxyPort ( const tr_session * );
|
||||
tr_proxy_type tr_sessionGetProxyType ( const tr_session * );
|
||||
const char* tr_sessionGetProxyPassword ( const tr_session * );
|
||||
void tr_sessionSetProxyEnabled ( tr_session *, int isEnabled );
|
||||
void tr_sessionSetProxyAuthEnabled ( tr_session *, int isEnabled );
|
||||
void tr_sessionSetProxy ( tr_session *, const char * proxy );
|
||||
void tr_sessionSetProxyPort ( tr_session *, int port );
|
||||
void tr_sessionSetProxyType ( tr_session *, tr_proxy_type );
|
||||
void tr_sessionSetProxyUsername ( tr_session *, const char * username );
|
||||
void tr_sessionSetProxyPassword ( tr_session *, const char * password );
|
||||
|
|
|
@ -161,6 +161,7 @@ addTask( void * vtask )
|
|||
|
||||
if( !task->range && session->isProxyEnabled ) {
|
||||
curl_easy_setopt( ch, CURLOPT_PROXY, session->proxy );
|
||||
curl_easy_setopt( ch, CURLOPT_PROXYPORT, session->proxyPort );
|
||||
curl_easy_setopt( ch, CURLOPT_PROXYTYPE, getCurlProxyType( session->proxyType ) );
|
||||
curl_easy_setopt( ch, CURLOPT_PROXYAUTH, CURLAUTH_ANY );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue