Permalink
Browse files

use pac to config mac proxy

  • Loading branch information...
1 parent 405ff7a commit b51d45164dbf1cade876c45b4bf03f41655425ca @iptton iptton committed Sep 14, 2012
Showing with 41 additions and 29 deletions.
  1. +1 −0 deploy.txt
  2. +18 −12 mainwindow.cpp
  3. +2 −0 publish
  4. +3 −0 rythem.pac
  5. +15 −15 rythem_zh_CN.ts
  6. +2 −2 setupproxy
View
@@ -4,3 +4,4 @@ lrelease $1/Rythem.pro
cp -f $1/qt_zh_CN.qm $2/Rythem.app/Contents/MacOS/
cp -f $1/rythem_zh_CN.qm $2/Rythem.app/Contents/MacOS/
cp -f $1/setupproxy $2/Rythem.app/Contents/MacOS/
+cp -f $1/rythem.pac $2/Rythem.app/Contents/MacOS/
View
@@ -167,12 +167,12 @@ QString getServiceName(){
return regNetworkservice.cap(1);
}
+
bool execScript(const QString &script){
QString service = getServiceName();
QProcess process;
qDebug()<<"script"<<script.arg(service);
QStringList args = script.arg(service).split(" ");
- //process.start(QString("sudo "),args);
process.start(script.arg(service));
QEventLoop eventLoop;
eventLoop.connect(&process,SIGNAL(finished(int)),&eventLoop,SLOT(quit()));
@@ -198,6 +198,18 @@ bool disableAutoProxyAndSetProxyForService(const QString& host, const int port){
return a & setProxyForService(host,port);
}
+bool setPAC(const QString& url){
+ return execScript(QString("networksetup -setautoproxyurl %1 %2").arg("%1",url));
+}
+bool setMyPAC(){
+ return setPAC(QString("file://local%1/rythem.pac").arg(appPath));
+}
+
+bool disableMyPac(){
+ return execScript(QString("networksetup -setautoproxystate %1 off"));
+}
+
+
#endif
// RyJsBridge
RyJsBridge::RyJsBridge(){
@@ -582,13 +594,9 @@ void MainWindow::toggleProxy(){
bool setProxySuccess = false;
if(_isUsingCapture){
if(_previousProxyInfo.isUsingPac == "1"){
- setProxySuccess = setAutoProxyUrl(_previousProxyInfo.pacUrl);
- }
- if(!_previousProxyInfo.enable){
- // TODO
- setProxySuccess = setProxySuccess && setProxyState(false);
+ setProxySuccess = setPAC(_previousProxyInfo.pacUrl);
}else{
- //setProxySuccess = setProxyForService(_previousProxyInfo.proxyString)
+ disableMyPac();
}
}else{
@@ -640,15 +648,13 @@ void MainWindow::toggleProxy(){
}else{
_previousProxyInfo.enable = false;
}
- qDebug()<<theService;
+ //qDebug()<<theService;
}
- execScript(QString("./setupproxy onlyATest %1 %2").arg("%1",( _previousProxyInfo.isUsingPac=="1"?"on":"off")));
+ //execScript(QString("./setupproxy onlyATest %1 %2").arg("%1",( _previousProxyInfo.isUsingPac=="1"?"on":"off")));
if(_previousProxyInfo.isUsingPac == "1"){
ProxyAutoConfig::instance()->setConfigByUrl(_previousProxyInfo.pacUrl);
- setProxySuccess = disableAutoProxyAndSetProxyForService(QString("127.0.0.1"),8889);
- }else{
- setProxySuccess = setProxyForService(QString("127.0.0.1"),8889);
}
+ setProxySuccess = setMyPAC();;
}
if(!setProxySuccess){// hack..
View
@@ -0,0 +1,2 @@
+#!/bin/sh
+# generate dmg pkg
View
@@ -0,0 +1,3 @@
+function FindProxyFoUrl(url,host){
+ return "PROXY 127.0.0.1:8889";
+}
View
@@ -145,7 +145,7 @@ Host: www.alloyteam.com
<translation type="obsolete">非windows系统需手动设置代理为 127.0.0.1:8889</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="365"/>
+ <location filename="mainwindow.cpp" line="377"/>
<source>-</source>
<translation type="unfinished">-</translation>
</message>
@@ -154,7 +154,7 @@ Host: www.alloyteam.com
<translation type="obsolete">请了</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="366"/>
+ <location filename="mainwindow.cpp" line="378"/>
<source>Please drag to Applications dir first
otherwise creat replace rule will cause crash on MacOS 10.8 (Mountain Lion)</source>
@@ -164,51 +164,51 @@ Host: www.alloyteam.com
否则在创建替换规则时 Rythem 会崩溃</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="374"/>
+ <location filename="mainwindow.cpp" line="386"/>
<source>&amp;File</source>
<translation type="unfinished">文件(&amp;F)</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="375"/>
+ <location filename="mainwindow.cpp" line="387"/>
<source>&amp;import session...</source>
<translation type="unfinished">导入会放(&amp;i)...</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="376"/>
+ <location filename="mainwindow.cpp" line="388"/>
<source>hide image requests</source>
<translation type="unfinished">隐藏图片请求</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="378"/>
+ <location filename="mainwindow.cpp" line="390"/>
<source>hide 304s</source>
<translation type="unfinished">隐藏304</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="380"/>
+ <location filename="mainwindow.cpp" line="392"/>
<source>show matching sessions only</source>
<translation type="unfinished">只显示匹配规则的请求</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="382"/>
+ <location filename="mainwindow.cpp" line="394"/>
<source>hide connect tunnels</source>
<translation type="unfinished">隐藏Connect遂道</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="390"/>
+ <location filename="mainwindow.cpp" line="402"/>
<source>select file to open</source>
<translation type="unfinished">选择文件</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="663"/>
- <location filename="mainwindow.cpp" line="692"/>
- <location filename="mainwindow.cpp" line="693"/>
+ <location filename="mainwindow.cpp" line="669"/>
+ <location filename="mainwindow.cpp" line="698"/>
+ <location filename="mainwindow.cpp" line="699"/>
<source>start capture</source>
<translation type="unfinished">开始抓包</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="672"/>
- <location filename="mainwindow.cpp" line="688"/>
- <location filename="mainwindow.cpp" line="689"/>
+ <location filename="mainwindow.cpp" line="678"/>
+ <location filename="mainwindow.cpp" line="694"/>
+ <location filename="mainwindow.cpp" line="695"/>
<source>stop capture</source>
<translation type="unfinished">停止抓包</translation>
</message>
View
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/bash -e
# usage
# setupproxy [serviceName] [cmd] <other arguments>
# cmd:
@@ -66,7 +66,7 @@ else
if test $? -eq 0
then
- onlyATest $*
+ onlyATest $*
${cmd} $*
exit $?
else

0 comments on commit b51d451

Please sign in to comment.