Skip to content

Commit

Permalink
3.8.1 LAN proxy move to system menu, improve X-Tunnel performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
xxnet committed Nov 19, 2017
1 parent d0c51f8 commit 45367b4
Show file tree
Hide file tree
Showing 43 changed files with 1,245 additions and 1,097 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@


### 最新状态:
2017-11-17
* X-Tunnel 稳定.[使用教程](https://github.com/XX-net/XX-Net/wiki/x-tunnel%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B)
2017-11-19
* X-Tunnel 请升级到3.8.1[使用教程](https://github.com/XX-net/XX-Net/wiki/x-tunnel%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B)

* GAE: 请升级到 3.7.18, 扫不到ip,请开启ipv6,请参考:
[如何开启IPv6](https://github.com/XX-net/XX-Net/wiki/%E5%A6%82%E4%BD%95%E5%BC%80%E5%90%AFIPv6)
Expand Down
2 changes: 1 addition & 1 deletion code/default/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ https://codeload.github.com/XX-net/XX-Net/zip/3.7.18


测试版(Test):
https://codeload.github.com/XX-net/XX-Net/zip/3.8.0
https://codeload.github.com/XX-net/XX-Net/zip/3.8.1


Android:
Expand Down
1 change: 1 addition & 0 deletions code/default/gae_proxy/local/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

import apis
25 changes: 25 additions & 0 deletions code/default/gae_proxy/local/apis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from web_control import user_config
import check_ip
from config import config
from xlog import getLogger
xlog = getLogger("gae_proxy")


def set_proxy(args):
xlog.info("set_proxy:%s", args)

user_config.user_special.proxy_enable = args["enable"]
user_config.user_special.proxy_type = args["type"]
user_config.user_special.proxy_host = args["host"]
try:
user_config.user_special.proxy_port = int(args["port"])
except:
user_config.user_special.proxy_port = 0

user_config.user_special.proxy_user = args["user"]
user_config.user_special.proxy_passwd = args["passwd"]

user_config.save()
config.load()

check_ip.load_proxy_config()
6 changes: 4 additions & 2 deletions code/default/gae_proxy/local/http1.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def work_loop(self):
self.request_task(task)

def request_task(self, task):
start_time = time.time()
task.set_state("h1_req")

self.ssl_sock.last_use_time = time.time()
Expand All @@ -120,7 +121,8 @@ def request_task(self, task):
response.begin(timeout=task.timeout)

except Exception as e:
xlog.warn("%s h1_request:%r", self.ip, e)
xlog.warn("%s h1_request:%s %r time_cost:%d inactive:%d", self.ip, task.url, e,
(time.time()-start_time)*1000, (time.time() - self.last_active_time)*1000)
google_ip.report_connect_closed(self.ssl_sock.ip, "request_fail")
self.task = task
self.close("request fail")
Expand Down Expand Up @@ -181,7 +183,7 @@ def request_task(self, task):
task.put_data(data)

except Exception as e:
xlog.warn("%s h1_request:%r", self.ip, e)
xlog.warn("%s h1 get data:%r", self.ip, e)

task.finish()
google_ip.report_connect_closed(self.ssl_sock.ip, "down fail")
Expand Down
2 changes: 1 addition & 1 deletion code/default/gae_proxy/local/http_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def check_free_worker(self):
self.close_cb(slowest_worker)

def request(self, headers, body, url, timeout):
# xlog.debug("task start request")
# xlog.debug("task start request:%s timeout:%d", url, timeout)
self.last_request_time = time.time()
q = Queue.Queue()
task = http_common.Task(headers, body, q, url, timeout)
Expand Down
2 changes: 1 addition & 1 deletion code/default/gae_proxy/local/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_data_path():

from xlog import getLogger
xlog = getLogger("gae_proxy")
xlog.set_buffer(2000)
xlog.set_buffer(1000)
if config.log_file:
log_file = os.path.join(data_gae_proxy_path, "local.log")
xlog.set_file(log_file)
Expand Down
25 changes: 2 additions & 23 deletions code/default/gae_proxy/local/web_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def save(self):
f.write("use_ipv6 = %s\n\n" % self.user_special.use_ipv6)

f.close()
xlog.info("save config to %s", CONFIG_USER_FILENAME)
except Exception as e:
xlog.warn("launcher.config save user config fail:%s %r", CONFIG_USER_FILENAME, e)

Expand Down Expand Up @@ -328,16 +329,8 @@ def req_log_handler(self):
cmd = "get_last"
if reqs["cmd"]:
cmd = reqs["cmd"][0]
if cmd == "set_buffer_size" :
if not reqs["buffer_size"]:
data = '{"res":"fail", "reason":"size not set"}'
mimetype = 'text/plain'
self.send_response_nc(mimetype, data)
return

buffer_size = reqs["buffer_size"][0]
xlog.set_buffer_size(buffer_size)
elif cmd == "get_last":
if cmd == "get_last":
max_line = int(reqs["max_line"][0])
data = xlog.get_last_lines(max_line)
elif cmd == "get_new":
Expand Down Expand Up @@ -470,19 +463,6 @@ def req_config_handler(self):
appid_updated = True
user_config.user_special.appid = appids

user_config.user_special.proxy_enable = self.postvars['proxy_enable'][0]
user_config.user_special.proxy_type = self.postvars['proxy_type'][0]
user_config.user_special.proxy_host = self.postvars['proxy_host'][0]
user_config.user_special.proxy_port = self.postvars['proxy_port'][0]
try:
user_config.user_special.proxy_port = int(user_config.user_special.proxy_port)
except:
user_config.user_special.proxy_port = 0

user_config.user_special.proxy_user = self.postvars['proxy_user'][0]
user_config.user_special.proxy_passwd = self.postvars['proxy_passwd'][0]
user_config.user_special.host_appengine_mode = self.postvars['host_appengine_mode'][0]

user_config.save()

config.load()
Expand All @@ -493,7 +473,6 @@ def req_config_handler(self):
http_dispatch.close_all_worker()

google_ip.reset()
check_ip.load_proxy_config()

data = '{"res":"success"}'
self.send_response_nc('text/html', data)
Expand Down
130 changes: 4 additions & 126 deletions code/default/gae_proxy/web_ui/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,67 +18,6 @@
</div>
</div> <!-- .span8 -->
</div> <!-- .row-fluid -->
<div class="row-fluid">
<div class="span4">
<label for="advanced-options"><i class="icon icon-chevron-right"></i> {{ _( "Advanced options" ) }}</label>
</div> <!-- .span4 -->
</div> <!-- .row-fluid -->
<div id="advanced-options" style="display: none;">
<div class="row-fluid">
<div class="span4">
<label for="enable-proxy">{{ _( "LAN proxy(Generally not needed)" ) }} <a href="https://github.com/XX-net/XX-Net/wiki/GoAgent-Intranet-proxy" target="_blank">({{ _( "Help" ) }})</a></label>
</div> <!-- .span4 -->
<div class="span8">
<input id="enable-proxy" type="checkbox" data-toggle="switch" />
</div> <!-- .span8 -->
</div> <!-- .row-fluid -->
<div id="proxy-options" style="display: none;">
<div class="row-fluid">
<div class="span4">
<label for="proxy-type">{{ _( "Proxy type" ) }}</label>
</div> <!-- .span4 -->
<div class="span8">
<select id="proxy-type">
<option value="HTTP">HTTP</option>
<option value="SOCKS4">SOCKS 4</option>
<option value="SOCKS5">SOCKS 5</option>
</select>
</div> <!-- .span8 -->
</div> <!-- .row-fluid -->
<div class="row-fluid">
<div class="span4">
<label for="proxy-host">{{ _( "Proxy IP address or domain name" ) }}</label>
</div> <!-- .span4 -->
<div class="span8">
<input id="proxy-host" type="text" placeholder="Example: 127.0.0.1" />
</div> <!-- .span8 -->
</div> <!-- .row-fluid -->
<div class="row-fluid">
<div class="span4">
<label for="proxy-port">{{ _( "Port" ) }}</label>
</div> <!-- .span4 -->
<div class="span8">
<input id="proxy-port" type="text" placeholder="Example: 808" />
</div> <!-- .span8 -->
</div> <!-- .row-fluid -->
<div class="row-fluid">
<div class="span4">
<label for="proxy-username">{{ _( "User name" ) }}</label>
</div> <!-- .span4 -->
<div class="span8">
<input id="proxy-username" type="text" />
</div> <!-- .span8 -->
</div> <!-- .row-fluid -->
<div class="row-fluid">
<div class="span4">
<label for="proxy-password">{{ _( "Password" ) }}</label>
</div> <!-- .span4 -->
<div class="span8">
<input id="proxy-password" type="password" />
</div> <!-- .span8 -->
</div> <!-- .row-fluid -->
</div> <!-- #proxy-options -->
</div> <!-- #advanced-options -->
<div class="row-fluid">
<div class="span12">
<button class="btn btn-primary btn-block" type="submit">{{ _( "Save" ) }}</button>
Expand All @@ -95,37 +34,6 @@
<script type="text/javascript">
title('{{ _( "Configure GAEProxy" ) }}');
</script>
<script type="text/javascript">
$(function() {
$('[data-toggle=switch]').wrap('<div class="switch" />').parent().bootstrapSwitch();
});
</script>
<script type="text/javascript">
$('label[for=advanced-options]').click(function() {
var isAdvancedOptionsShown = $('#advanced-options').is(':visible');

if ( !isAdvancedOptionsShown ) {
$('i.icon', this).removeClass('icon-chevron-right');
$('i.icon', this).addClass('icon-chevron-down');
$('#advanced-options').slideDown();
} else {
$('i.icon', this).removeClass('icon-chevron-down');
$('i.icon', this).addClass('icon-chevron-right');
$('#advanced-options').slideUp();
}
});
</script>
<script type="text/javascript">
$('#enable-proxy').change(function() {
var isChecked = $(this).is(':checked');

if ( isChecked ) {
$('#proxy-options').slideDown();
} else {
$('#proxy-options').slideUp();
}
});
</script>
<script type="text/javascript">
$('#gae-appid-field').click(function(){
$('#gae-appid-tip').removeClass('hide');
Expand Down Expand Up @@ -154,20 +62,6 @@
$('#deploy-via-gae').parent().addClass('switch-on');
$('#deploy-via-gae').prop('checked', true);
}

if ( typeof(result['proxy_enable']) != 'undefined' && result['proxy_enable'] != 0 ) {
$('#enable-proxy').parent().removeClass('switch-off');
$('#enable-proxy').parent().addClass('switch-on');

$('#enable-proxy').prop('checked', true);
$('#proxy-options').slideDown();
}
$('#proxy-type').val(result['proxy_type']);
$('#proxy-host').val(result['proxy_host']);
$('#proxy-port').val(result['proxy_port']);
$('#proxy-username').val(result['proxy_user']);
$('#proxy-password').val(result['proxy_passwd']);

},
error: function(){
tip('{{ _( "Failed reading the settings." ) }}', 'error');
Expand All @@ -178,34 +72,18 @@
<script type="text/javascript">
function onSubmit() {
var gaeAppId = $('#gae-appid').val(),
hostAppEngine = $('#deploy-via-gae').is(':checked') ? 'gae' : 'direct',
enableProxy = $('#enable-proxy').is(':checked') ? 1 : 0,
proxyType = $('#proxy-type').val(),
proxyHost = $('#proxy-host').val(),
proxyPort = $('#proxy-port').val(),
proxyUsername = $('#proxy-username').val(),
proxyPassword = $('#proxy-password').val();

proxyPort = parseInt(proxyPort, 10);
hostAppEngine = $('#deploy-via-gae').is(':checked') ? 'gae' : 'direct';

tip('{{ _( "Wait for checking setting..." ) }}', 'info');

return setConfig(gaeAppId, hostAppEngine,
enableProxy, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword);
return setConfig(gaeAppId, hostAppEngine);
}
</script>
<script type="text/javascript">
function setConfig(gaeAppId, hostAppEngine,
enableProxy, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) {
function setConfig(gaeAppId, hostAppEngine) {
var config = {
'appid': gaeAppId,
'host_appengine_mode': hostAppEngine,
'proxy_enable': enableProxy,
'proxy_type': proxyType,
'proxy_host': proxyHost,
'proxy_port': proxyPort,
'proxy_user': proxyUsername,
'proxy_passwd': proxyPassword
'host_appengine_mode': hostAppEngine
};

$.ajax({
Expand Down
4 changes: 2 additions & 2 deletions code/default/gae_proxy/web_ui/scan_setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</div> <!-- .row-fluid -->
<div class="row-fluid">
<div class="span3">
<label for="scan-ip-thread-num">{{ _("Max scan thread count") }}</label>
<label for="scan-ip-thread-num">{{ _("Max scan thread count") }}(0-200)</label>
</div> <!-- .span3 -->
<div class="span6">
<input id="scan-ip-thread-num" type="text" />
<input id="scan-ip-thread-num" type="number" step="1" min="0" max="200" />
</div> <!-- .span6 -->
</div> <!-- .row-fluid -->

Expand Down
2 changes: 1 addition & 1 deletion code/default/gae_proxy/web_ui/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ <h3>{{ _( "Diagnostic Info" ) }}</h3>
}

if ( is_public_appid(result['gae_appid']) ){
if ( result['out_of_quota_appids'].length > 20 ){
if ( result['out_of_quota_appids'].length > 200 ){
return updateProperty('#noob-info', '{{ _( "You are using public APPID. You are recommended to <a href=\"https://github.com/XX-net/XX-Net/wiki/Register-Google-appid\" target=\"_blank\">deploy your own APPID</a>" ) }}', 'hard');
}
}
Expand Down
1 change: 1 addition & 0 deletions code/default/launcher/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
config = {}
need_save_config = False


def load():
global config, config_path
try:
Expand Down
Loading

0 comments on commit 45367b4

Please sign in to comment.