예제 #1
0
    def get_nodes(self):
        base = 'http://www.gogovpn.org/{}/user'.format(self.config['service'])
        url = dict(
            login='******'.format(base),
            ss_login='******'.format(base),
            ss_hosts='{}/node.php'.format(base))

        log.info('Logging in GOGOVPN as {}'.format(self.config['email']))

        r = self.session.post(url.get('login'), dict(
            email=self.config['email'],
            passwd=self.config['password'],
            remember_me='on'))

        r.raise_for_status()

        try:
            r = r.json()
        except:
            raise Exception('Unknown error.')

        if r.get('ok') != '1':
            try:
                msg = r.get('msg').encode()
            except:
                msg = 'None.'
            raise Exception('Failed to login: {}'.format(msg))

        log.info('Getting SS login')
        r = self.session.get(url.get('ss_login'))
        r.raise_for_status()

        try:
            port = self.find_value('端口', '\d+', r.content)
            password = self.find_value('密码', '\w+', r.content)
            method = self.find_value('加密方式', '[\w\-]+', r.content)
        except:
            raise Exception('Your service may have been disabled.')

        log.info('Getting SS hosts')
        r = self.session.get(url.get('ss_hosts'))
        r.raise_for_status()
        hosts = re.findall(
            r'<b[^>]*>\s*(\w[\w\-]*\.gogovpn\.org)\s*</b>',
            r.content)

        nodes = Nodes()
        nodes.get_nodes(hosts, port, password, method)
        return nodes
예제 #2
0
    def get_nodes(self):
        log.info('Getting nodes from CloudSS...')
        url = self.url_product_details + self.product_ids[0]
        r = self.session.get(url)
        r.raise_for_status()
        # 节点列表, 加密方式, 连接端口, 连接密码
        method = self.find_value(r.content, '加密方式')
        port = self.find_value(r.content, '连接端口')
        password = self.find_value(r.content, '连接密码')
        hosts = self.find_value(r.content, '节点列表')
        hosts = re.findall('(?:[\w\-]+\.)+[\w\-]+', hosts)

        nodes = Nodes()
        nodes.get_nodes(hosts, port, password, method)
        return nodes
예제 #3
0
파일: cloudss.py 프로젝트: ztmdsbt/ssflow
    def get_nodes(self):
        log.info('Getting nodes from CloudSS...')
        url = self.url_product_details + self.product_ids[0]
        r = self.session.get(url)
        r.raise_for_status()
        # 节点列表, 加密方式, 连接端口, 连接密码
        method = self.find_value(r.content, '加密方式')
        port = self.find_value(r.content, '连接端口')
        password = self.find_value(r.content, '连接密码')
        hosts = self.find_value(r.content, '节点列表')
        hosts = re.findall('(?:[\w\-]+\.)+[\w\-]+', hosts)

        nodes = Nodes()
        nodes.get_nodes(hosts, port, password, method)
        return nodes
예제 #4
0
    def get_nodes(self):
        base = 'http://www.gogovpn.org/{}/user'.format(self.config['service'])
        url = dict(login='******'.format(base),
                   ss_login='******'.format(base),
                   ss_hosts='{}/node.php'.format(base))

        log.info('Logging in GOGOVPN as {}'.format(self.config['email']))

        r = self.session.post(
            url.get('login'),
            dict(email=self.config['email'],
                 passwd=self.config['password'],
                 remember_me='on'))

        r.raise_for_status()

        try:
            r = r.json()
        except:
            raise Exception('Unknown error.')

        if r.get('ok') != '1':
            try:
                msg = r.get('msg').encode()
            except:
                msg = 'None.'
            raise Exception('Failed to login: {}'.format(msg))

        log.info('Getting SS login')
        r = self.session.get(url.get('ss_login'))
        r.raise_for_status()

        try:
            port = self.find_value('端口', '\d+', r.content)
            password = self.find_value('密码', '\w+', r.content)
            method = self.find_value('加密方式', '[\w\-]+', r.content)
        except:
            raise Exception('Your service may have been disabled.')

        log.info('Getting SS hosts')
        r = self.session.get(url.get('ss_hosts'))
        r.raise_for_status()
        hosts = re.findall(r'<b[^>]*>\s*(\w[\w\-]*\.gogovpn\.org)\s*</b>',
                           r.content)

        nodes = Nodes()
        nodes.get_nodes(hosts, port, password, method)
        return nodes
예제 #5
0
    def get_nodes(self):
        log.info('Getting nodes from iShadowsocks...')
        r = self.session.get('http://www.ishadowsocks.com/')
        r.raise_for_status()

        m = re.findall(
            r'<h4>[^<]*服务器地址\s*(?::|:)\s*([\w\-\.]+)\s*</h4>\s*' +
            r'<h4>[^<]*端口\s*(?::|:)\s*(\d+)\s*</h4>\s*' +
            r'<h4>[^<]*密码\s*(?::|:)\s*(.*?)\s*</h4>\s*' +
            r'<h4>[^<]*加密方式\s*(?::|:)\s*([\w\-]+)\s*</h4>',
            r.content)

        nodes = Nodes()
        for n in m:
            nodes.get_nodes(
                hosts=(n[0],),
                port=n[1],
                password=n[2],
                method=n[3])

        return nodes