Skip to content

Commit

Permalink
merge new web ui
Browse files Browse the repository at this point in the history
  • Loading branch information
xxnet committed Apr 22, 2015
1 parent 18b4938 commit 8bc7873
Show file tree
Hide file tree
Showing 45 changed files with 10,767 additions and 11,377 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ XX-Net

下载链接:
==========
https://codeload.github.com/XX-net/XX-Net/zip/1.9.2
https://codeload.github.com/XX-net/XX-Net/zip/1.9.3

(1.8.3之前的用户,请重新部署服务端)

Expand Down
16 changes: 13 additions & 3 deletions goagent/3.1.49/local/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
import re
import io
import collections
import logging



Expand All @@ -31,15 +31,25 @@ def load(self):
if not os.path.isdir(self.DATA_PATH):
self.DATA_PATH = current_path

# load ../../../data/goagent/config.ini
# load ../../../data/goagent/config.ini, set by web_ui
self.CONFIG_USER_FILENAME = os.path.abspath( os.path.join(self.DATA_PATH, 'config.ini'))

self.CONFIG.read(self.CONFIG_FILENAME)
if os.path.isfile(self.CONFIG_USER_FILENAME):
with open(self.CONFIG_USER_FILENAME, 'rb') as fp:
content = fp.read()
self.CONFIG.readfp(io.BytesIO(content))

# load ../../../data/goagent/manual.ini, set by manual
self.CONFIG_MANUAL_FILENAME = os.path.abspath( os.path.join(self.DATA_PATH, 'manual.ini'))
if os.path.isfile(self.CONFIG_MANUAL_FILENAME):
with open(self.CONFIG_MANUAL_FILENAME, 'rb') as fp:
content = fp.read()
try:
self.CONFIG.readfp(io.BytesIO(content))
logging.info("load manual.ini success")
except Exception as e:
logging.exception("data/goagent/manual.ini load error:%s", e)

self.LISTEN_IP = self.CONFIG.get('listen', 'ip')
self.LISTEN_PORT = self.CONFIG.getint('listen', 'port')
self.LISTEN_VISIBLE = self.CONFIG.getint('listen', 'visible')
Expand Down
3 changes: 1 addition & 2 deletions goagent/3.1.49/local/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ def log(level, console_color, html_color, fmt, *args, **kwargs):
set_console_color(reset_color)

last_no += 1
string = string.replace('\n', '<br>')
buffer[last_no] = '<font color="%s">%s</font>' % (html_color, string)
buffer[last_no] = string
buffer_len = len(buffer)
if buffer_len > buffer_size:
del buffer[last_no - buffer_size]
Expand Down
2 changes: 1 addition & 1 deletion goagent/3.1.49/local/proxy_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def do_CONNECT_AGENT(self):
self.path = 'https://%s%s' % (self.headers['Host'], self.path)
logging.debug('GAE CONNECT %s %s', self.command, self.path)
if self.command not in self.gae_support_methods:
if host.endswith(".google.com") or host.endswith(config.HOSTS_FWD_ENDSWITH):
if host.endswith(".google.com") or host.endswith(config.HOSTS_FWD_ENDSWITH) or host.endswith(config.HOSTS_GAE_ENDSWITH):
if host in config.HOSTS_GAE:
gae_set = [s for s in config.HOSTS_GAE]
gae_set.remove(host)
Expand Down
18 changes: 12 additions & 6 deletions goagent/3.1.49/local/web_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ def req_status_handler(self):
"ip_connect_interval":config.CONFIG.getint("google_ip", "ip_connect_interval")
}
data = json.dumps(res_arr)

self.send_response('application/json', data)
self.send_response('text/html', data)

def req_config_handler(self):
req = urlparse.urlparse(self.path).query
Expand All @@ -435,7 +434,7 @@ def req_config_handler(self):
data = json.dumps(user_config, default=lambda o: o.__dict__)
elif reqs['cmd'] == ['set_config']:
user_config.appid = self.postvars['appid'][0]
user_config.password = self.postvars['passwd'][0]
user_config.password = self.postvars['password'][0]
user_config.proxy_enable = self.postvars['proxy_enable'][0]
user_config.proxy_type = self.postvars['proxy_type'][0]
user_config.proxy_host = self.postvars['proxy_host'][0]
Expand All @@ -447,14 +446,14 @@ def req_config_handler(self):
user_config.save()

data = '{"res":"success"}'
self.send_response('application/json', data)
self.send_response('text/html', data)

http_request("http://127.0.0.1:8085/init_module?module=goagent&cmd=restart")
return
except Exception as e:
logging.exception("req_config_handler except:%s", e)
data = '{"res":"fail", "except":"%s"}' % e
self.send_response('application/json', data)
self.send_response('text/html', data)


def req_deploy_handler(self):
Expand Down Expand Up @@ -486,6 +485,13 @@ def req_deploy_handler(self):
except Exception as e:
data = '{"res":"%s", "time":"%s"}' % (e, time_now)

elif reqs['cmd'] == ['cancel']:
if RemoteContralServerHandler.deploy_proc and RemoteContralServerHandler.deploy_proc.poll() == None:
RemoteContralServerHandler.deploy_proc.kill()
data = '{"res":"deploy is killed", "time":"%s"}' % (time_now)
else:
data = '{"res":"deploy is not running", "time":"%s"}' % (time_now)

elif reqs['cmd'] == ['get_log']:
if self.deploy_proc and os.path.isfile(log_path):
with open(log_path, "r") as f:
Expand All @@ -502,7 +508,7 @@ def req_deploy_handler(self):

data = json.dumps({'status':status,'log':content, 'time':time_now})

self.send_response('application/json', data)
self.send_response('text/html', data)

def req_ip_list_handler(self):
data = ""
Expand Down
4 changes: 3 additions & 1 deletion goagent/3.1.49/server/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ def upload(appid, email, password):
except Exception as e:
my_stdout.write("upload fail: %s\n\n" % e)
if i < 9:
my_stdout.write("Retry again.\n\n")
my_stdout.write("Retry %d time...\n\n" % (i + 1))
time.sleep(1)
else:
my_stdout.write("Retry max time, failed.\n\n" % (i + 1))
return False

finally:
Expand Down
Loading

0 comments on commit 8bc7873

Please sign in to comment.