def _build_ss_info(): ss = Shadowsocks.find_latest(Shadowsocks.workers) if not ss.running: ss.start() content = 'Id: %d\n' \ 'Port: %d\n' \ 'Password: %s' \ % (ss.index, ss.port, ss.password) return content
def get(self): if self.request.path == '/save': Shadowsocks.save_config(Shadowsocks.workers) self.write("OK!") return sid = self.get_query_argument('id', None) if sid is None: self.redirect('/?id=%d' % Shadowsocks.find_latest(Shadowsocks.workers).index) return ss = self._get_ss(sid) qrcode = ss.qrcode(self._get_host()) self.render("index.html", config=ss, qrcode=qrcode)