Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
1f8654db
Commit
1f8654db
authored
Mar 23, 2016
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Proxy Authentication
parent
7de9a096
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
25 deletions
+7
-25
request.js
modules/request.js
+0
-18
app.entry.jsx
source/app.entry.jsx
+3
-3
aproxy.jsx
source/modules/settings/aproxy.jsx
+4
-4
No files found.
modules/request.js
View file @
1f8654db
...
...
@@ -12,7 +12,6 @@ const logger = log4js.getLogger('Request');
var
aproxymode
=
"noproxy"
;
var
aproxyuri
=
""
;
var
aproxyauth
=
""
;
class
Request
{
...
...
@@ -24,18 +23,11 @@ class Request {
ipcMain
.
on
(
'aproxytest'
,
(
event
,
opts
)
=>
{
var
_superagent
=
require
(
'superagent'
);
var
_aproxyuri
=
opts
[
'aproxyuri'
];
var
_aproxyauth
=
opts
[
'aproxyauth'
]
||
""
;
logger
.
debug
(
"[aProxy] Test Proxy - "
+
_aproxyuri
+
" - Connect to "
+
opts
[
'url'
]);
require
(
'superagent-proxy'
)(
superagent
);
if
(
!
_aproxyauth
)
{
_superagent
.
Request
.
prototype
.
auth
=
function
(
arg
)
{
return
this
;
};
};
_superagent
.
get
(
opts
[
'url'
])
.
proxy
(
_aproxyuri
)
.
auth
(
_aproxyauth
)
.
timeout
(
5000
)
.
end
((
err
,
ret
)
=>
{
if
(
err
)
{
...
...
@@ -52,22 +44,13 @@ class Request {
ipcMain
.
on
(
'aproxy'
,
(
event
,
opts
)
=>
{
aproxymode
=
opts
[
'aproxymode'
];
aproxyuri
=
opts
[
'aproxyuri'
];
aproxyauth
=
opts
[
'aproxyauth'
];
logger
.
debug
(
"[aProxy] Set Proxy Mode - "
+
(
aproxymode
==
"manualproxy"
?
aproxyuri
:
" noproxy"
));
if
(
aproxymode
==
"noproxy"
)
{
superagent
.
Request
.
prototype
.
proxy
=
function
(
arg
)
{
return
this
;
};
superagent
.
Request
.
prototype
.
auth
=
function
(
arg
)
{
return
this
;
};
}
else
{
require
(
'superagent-proxy'
)(
superagent
);
if
(
!
aproxyauth
)
{
superagent
.
Request
.
prototype
.
auth
=
function
(
arg
)
{
return
this
;
};
};
};
});
// 监听请求
...
...
@@ -78,7 +61,6 @@ class Request {
.
post
(
opts
[
'url'
])
.
set
(
'User-Agent'
,
'antSword/1.0'
)
.
proxy
(
aproxyuri
)
.
auth
(
aproxyauth
)
.
type
(
'form'
)
.
timeout
(
5000
)
.
send
(
opts
[
'data'
])
...
...
source/app.entry.jsx
View file @
1f8654db
...
...
@@ -41,17 +41,17 @@ var _aproxyusername = localStorage.getItem('aproxyusername');
var
_aproxypassword
=
localStorage
.
getItem
(
'aproxypassword'
);
antSword
[
'aproxymode'
]
=
_aproxymode
;
antSword
[
'aproxyuri'
]
=
_aproxyprotocol
+
"://"
+
_aproxyserver
+
":"
+
_aproxyport
;
if
(
_aproxyusername
==
""
||
_aproxyusername
==
null
||
_aproxypassword
==
""
||
_aproxypassword
==
null
)
{
antSword
[
'aproxyauth'
]
=
""
;
}
else
{
antSword
[
'aproxyauth'
]
=
_aproxyusername
+
":"
+
_aproxypassword
;
}
antSword
[
'aproxyuri'
]
=
_aproxyprotocol
+
"://"
+
antSword
[
'aproxyauth'
]
+
"@"
+
_aproxyserver
+
":"
+
_aproxyport
;
ipcRenderer
.
send
(
'aproxy'
,
{
aproxymode
:
antSword
[
'aproxymode'
],
aproxyuri
:
antSword
[
'aproxyuri'
],
aproxyauth
:
antSword
[
'aproxyauth'
]
aproxyuri
:
antSword
[
'aproxyuri'
]
});
antSword
[
'ipcRenderer'
]
=
ipcRenderer
;
...
...
source/modules/settings/aproxy.jsx
View file @
1f8654db
...
...
@@ -41,7 +41,7 @@ class AProxy {
{
type
:
'combo'
,
label
:
LANG
[
'form'
][
'proxy'
][
'protocol'
],
readonly
:
true
,
name
:
'protocol'
,
options
:[
{
text
:
'HTTP'
,
value
:
'http'
,
selected
:
aproxyprotocol
===
'http'
},
{
text
:
'HTTPS'
,
value
:
'https'
,
selected
:
aproxyprotocol
===
'https'
},
{
text
:
'SOCKS5'
,
value
:
'socks
5'
,
selected
:
aproxyprotocol
===
'socks5
'
},
{
text
:
'SOCKS5'
,
value
:
'socks
'
,
selected
:
aproxyprotocol
===
'socks
'
},
{
text
:
'SOCKS4'
,
value
:
'socks4'
,
selected
:
aproxyprotocol
===
'socks4'
},
]},
{
type
:
'input'
,
label
:
LANG
[
'form'
][
'proxy'
][
'server'
],
name
:
'server'
,
required
:
true
,
validate
:
"NotEmpty"
,
value
:
aproxyserver
},
...
...
@@ -99,13 +99,14 @@ class AProxy {
var
loadindex
=
layer
.
load
(
2
,
{
time
:
6
*
1000
});
var
_formvals
=
form
.
getValues
();
var
_server
=
_formvals
[
'server'
].
replace
(
/.+:
\/\/
/
,
''
).
replace
(
/:.+/
,
''
);
var
_aproxyuri
=
_formvals
[
'protocol'
]
+
'://'
+
_server
+
':'
+
_formvals
[
'port'
];
var
_aproxyauth
=
""
;
if
(
_formvals
[
'username'
]
==
""
||
_formvals
[
'password'
]
==
""
||
_formvals
[
'username'
]
==
null
||
_formvals
[
'password'
]
==
null
)
{
_aproxyauth
=
""
;
}
else
{
_aproxyauth
=
_formvals
[
'username'
]
+
":"
+
_formvals
[
'password'
];
}
var
_aproxyuri
=
_formvals
[
'protocol'
]
+
'://'
+
_aproxyauth
+
'@'
+
_server
+
':'
+
_formvals
[
'port'
];
antSword
[
'ipcRenderer'
]
.
on
(
'aproxytest-error'
,
(
event
,
err
)
=>
{
layer
.
close
(
loadindex
);
...
...
@@ -117,8 +118,7 @@ class AProxy {
})
.
send
(
'aproxytest'
,{
url
:
testurl
||
'http://uyu.us'
,
aproxyuri
:
_aproxyuri
,
aproxyauth
:
_aproxyauth
aproxyuri
:
_aproxyuri
});
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment