コード例 #1
0
    def __init__(self, sock, client, args, logger=None):
        self.connection = sock
        sock.setblocking(1)
        sock.settimeout(300)
        self.rfile = socket._fileobject(self.connection, "rb", self.rbufsize, close=True)
        self.wfile = socket._fileobject(self.connection, "wb", self.wbufsize, close=True)
        self.client_address = client
        self.args = args
        if logger:
            self.logger = logger
        else:
            self.logger = xlog.getLogger("simple_http_server")

        self.setup()
コード例 #2
0
ファイル: front.py プロジェクト: Suwmlee/XX-Net
import os

import xlog
logger = xlog.getLogger("cloudfront_front")
logger.set_buffer(500)

from front_base.openssl_wrap import SSLContext
from front_base.ip_manager import IpManager
from front_base.ip_source import Ipv4RangeSource
from front_base.http_dispatcher import HttpsDispatcher
from front_base.connect_manager import ConnectManager
from front_base.check_ip import CheckIp

from connect_creator import ConnectCreator
from config import Config
import host_manager
from gae_proxy.local import check_local_network


current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir, os.pardir))
data_path = os.path.abspath(os.path.join(root_path, os.pardir, os.pardir, 'data'))
module_data_path = os.path.join(data_path, 'x_tunnel')


class Front(object):
    name = "cloudfront_front"

    def __init__(self):
        self.running = True
        self.last_host = "center.xx-net.net"
コード例 #3
0
    if sys.platform == "win32":
        win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
        sys.path.append(win32_lib)
    elif sys.platform.startswith("linux"):
        linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
        sys.path.append(linux_lib)

import OpenSSL
SSLError = OpenSSL.SSL.WantReadError

import socks
from config import config

from xlog import getLogger
xlog = getLogger("cloudflare_front")


max_timeout = 5

default_socket = socket.socket


def load_proxy_config():
    global default_socket
    if config.PROXY_ENABLE:

        if config.PROXY_TYPE == "HTTP":
            proxy_type = socks.HTTP
        elif config.PROXY_TYPE == "SOCKS4":
            proxy_type = socks.SOCKS4
コード例 #4
0
ファイル: test.py プロジェクト: Suwmlee/XX-Net
if sys.platform == "win32":
    win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
    sys.path.append(win32_lib)
elif sys.platform.startswith("linux"):
    linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
    sys.path.append(linux_lib)
elif sys.platform == "darwin":
    darwin_lib = os.path.abspath( os.path.join(python_path, 'lib', 'darwin'))
    sys.path.append(darwin_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    sys.path.append(extra_lib)


from front import front
from xlog import getLogger
xlog = getLogger("tls_relay")


def t1():
    content, status, response = front.request("GET", "scan1.xx-net.net", timeout=1000)
    print status

    del response

    content, status, response = front.request("GET", "scan1.xx-net.net", timeout=1000)
    print status

    front.stop()


if __name__ == '__main__':
コード例 #5
0
ファイル: client.py プロジェクト: comtao/XX-Net

def create_data_path():
    if not os.path.isdir(data_path):
        os.mkdir(data_path)

    if not os.path.isdir(data_xtunnel_path):
        os.mkdir(data_xtunnel_path)


create_data_path()

from xlog import getLogger

log_file = os.path.join(data_xtunnel_path, "client.log")
xlog = getLogger("x_tunnel", buffer_size=500, file_name=log_file)

import xconfig
from proxy_handler import Socks5Server
import global_var as g
import proxy_session

import web_control
# don't remove, launcher web_control need it.


def load_config():
    if len(sys.argv) > 2 and sys.argv[1] == "-f":
        config_path = sys.argv[2]
    else:
        config_path = os.path.join(data_xtunnel_path, 'client.json')
コード例 #6
0
ファイル: check_ip.py プロジェクト: chenqiuyan/XX-Net
if sys.platform == "win32":
    win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
    sys.path.append(win32_lib)
elif sys.platform.startswith("linux"):
    linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
    sys.path.append(linux_lib)
elif sys.platform == "darwin":
    darwin_lib = os.path.abspath( os.path.join(python_path, 'lib', 'darwin'))
    sys.path.append(darwin_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    sys.path.append(extra_lib)


import xlog
logger = xlog.getLogger("cloudflare_front")
logger.set_buffer(500)

from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.check_ip import CheckIp


from config import Config


if __name__ == "__main__":
    # case 1: only ip
    # case 2: ip + domain
    #    connect use domain
コード例 #7
0
ファイル: google_ip.py プロジェクト: Marstorm/Router
# based on checkgoogleip '*****@*****.**'

import threading
import operator
import time
import Queue
import os

current_path = os.path.dirname(os.path.abspath(__file__))

import check_local_network
import check_ip
import google_ip_range

from xlog import getLogger
xlog = getLogger("gae_ip")
xlog.setLevel("WARN")
from config import config
import connect_control
from scan_ip_log import scan_ip_log


######################################
# about ip connect time and handshake time
# handshake time is double of connect time in common case.
# after connect and handshaked, http get time is like connect time
#
# connect time is zero if you use socks proxy.
#
#
# most case, connect time is 300ms - 600ms.
コード例 #8
0
import os

all_fronts = []
light_fronts = []
session_fronts = []

from . import global_var as g

from xlog import getLogger

current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
data_path = os.path.abspath(os.path.join(root_path, os.pardir, os.pardir, 'data'))
data_xtunnel_path = os.path.join(data_path, 'x_tunnel')

xlog = getLogger("x_tunnel", log_path=data_xtunnel_path, save_start_log=500, save_warning_log=True)


def init():
    if g.config.enable_gae_proxy:
        from . import gae_front
        if gae_front.get_dispatcher():
            all_fronts.append(gae_front)
            session_fronts.append(gae_front)
            light_fronts.append(gae_front)

    if g.config.enable_cloudflare:
        from .cloudflare_front.front import front as cloudflare_front
        all_fronts.append(cloudflare_front)
        session_fronts.append(cloudflare_front)
        light_fronts.append(cloudflare_front)
コード例 #9
0
ファイル: scan_ip_log.py プロジェクト: Marstorm/Router
import os
import shutil
import time

from xlog import getLogger

xlog = getLogger("gae_ip")
xlog.setLevel("WARN")
from config import config


class Scan_ip_log():
    max_lines_per_log_file = 3000

    def __init__(self):
        self.log_path = os.path.join(config.DATA_PATH, "scan_ip.log")
        self.open_log()

    def get_log_content(self):
        if not os.path.isfile(self.log_path):
            return ""

        with open(self.log_path, "r") as fd:
            content = fd.read()
            return content

    def open_log(self):
        if os.path.isfile(self.log_path):
            with open(self.log_path, "r") as fd:
                lines = fd.readlines()
                line_num = len(lines)
コード例 #10
0
ファイル: check_ip.py プロジェクト: sbtger/vpn
if sys.platform == "win32":
    win32_lib = os.path.abspath(os.path.join(python_path, 'lib', 'win32'))
    sys.path.append(win32_lib)
elif sys.platform.startswith("linux"):
    linux_lib = os.path.abspath(os.path.join(python_path, 'lib', 'linux'))
    sys.path.append(linux_lib)
elif sys.platform == "darwin":
    darwin_lib = os.path.abspath(os.path.join(python_path, 'lib', 'darwin'))
    sys.path.append(darwin_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    sys.path.append(extra_lib)

import utils
import xlog
logger = xlog.getLogger("cloudflare_front")
logger.set_buffer(500)

from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.check_ip import CheckIp
from front_base.host_manager import HostManagerBase

from config import Config


def check_all_domain(check_ip):
    with open(os.path.join(current_path, "front_domains.json"), "r") as fd:
        content = fd.read()
        cs = json.loads(content)
        for host in cs:
コード例 #11
0
import datetime
import threading
import mimetools
import socket
import errno
import sys
import select
import time
import json
import base64
import hashlib
import struct

import xlog

logging = xlog.getLogger("simple_http_server")


class GetReqTimeout(Exception):
    pass


class ParseReqFail(Exception):
    def __init__(self, message):
        self.message = message

    def __str__(self):
        # for %s
        return repr(self.message)

    def __repr__(self):
コード例 #12
0

def create_data_path():
    if not os.path.isdir(data_path):
        os.mkdir(data_path)

    if not os.path.isdir(data_xtunnel_path):
        os.mkdir(data_xtunnel_path)


create_data_path()

from xlog import getLogger

log_file = os.path.join(data_xtunnel_path, "client.log")
xlog = getLogger("x_tunnel", buffer_size=500, file_name=log_file)

import xconfig
from proxy_handler import Socks5Server
import global_var as g
import proxy_session
import simple_http_server
import front_dispatcher

import web_control
# don't remove, launcher web_control need it.


def load_config():
    if len(sys.argv) > 2 and sys.argv[1] == "-f":
        config_path = sys.argv[2]
コード例 #13
0
    if not os.path.isdir(data_path):
        os.mkdir(data_path)

    if not os.path.isdir(data_launcher_path):
        os.mkdir(data_launcher_path)

    data_gae_proxy_path = os.path.join(data_path, 'gae_proxy')
    if not os.path.isdir(data_gae_proxy_path):
        os.mkdir(data_gae_proxy_path)

create_data_path()


from xlog import getLogger
log_file = os.path.join(data_launcher_path, "launcher.log")
xlog = getLogger("launcher", file_name=log_file)


def uncaughtExceptionHandler(type_, value, traceback):
    if type == KeyboardInterrupt:  # Ctrl + C on console
        xlog.warn("KeyboardInterrupt, exiting...")
        module_init.stop_all()
        os._exit(0)

    print("uncaught Exception:", type_, value, traceback)
    with open(os.path.join(data_launcher_path, "error.log"), "a") as fd:
        now = datetime.now()
        time_str = now.strftime("%b %d %H:%M:%S.%f")[:19]
        fd.write("%s type:%s value=%s traceback:%s" % (time_str, type_, value, traceback))
    xlog.error("uncaught Exception, type=%s value=%s traceback:%s", type_, value, traceback)
    # sys.exit(1)
コード例 #14
0
ファイル: check_ip.py プロジェクト: wuqundong520/fanqiang
sys.path.append(noarch_lib)

if sys.platform == "win32":
    win32_lib = os.path.abspath(os.path.join(python_path, 'lib', 'win32'))
    sys.path.append(win32_lib)
elif sys.platform.startswith("linux"):
    linux_lib = os.path.abspath(os.path.join(python_path, 'lib', 'linux'))
    sys.path.append(linux_lib)
elif sys.platform == "darwin":
    darwin_lib = os.path.abspath(os.path.join(python_path, 'lib', 'darwin'))
    sys.path.append(darwin_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    sys.path.append(extra_lib)

import xlog
logger = xlog.getLogger("tls_relay")
logger.set_buffer(500)

from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.check_ip import CheckIp

from config import Config

if __name__ == "__main__":
    # case 1: only ip
    # case 2: ip + domain
    #    connect use domain

    if len(sys.argv) > 1:
        ip = sys.argv[1]
コード例 #15
0
ファイル: gtk_tray.py プロジェクト: CyrusYzGTt/XX-Net
#!/usr/bin/env python
# coding:utf-8
# Contributor:
#      Phus Lu        <*****@*****.**>
import os
import sys
import webbrowser

from xlog import getLogger
xlog = getLogger("launcher")

import config
if __name__ == "__main__":
    current_path = os.path.dirname(os.path.abspath(__file__))
    python_path = os.path.abspath( os.path.join(current_path, os.pardir, 'python27', '1.0'))
    noarch_lib = os.path.abspath( os.path.join(python_path, 'lib', 'noarch'))
    sys.path.append(noarch_lib)

#Only enable AppIndicator in the DEs that are Unity and QT-based
enable_appind = False
if 'XDG_CURRENT_DESKTOP' in os.environ:
    cur_desktops = os.environ['XDG_CURRENT_DESKTOP'].split(':')
    if {'Unity', 'KDE', 'LXQt', 'ENLIGHTENMENT'}.intersection(cur_desktops):
        enable_appind = True

try:
    import pygtk
    pygtk.require('2.0')
    import gtk
    import gtk.gdk as gdk
    use_gi = False
コード例 #16
0
ファイル: test.py プロジェクト: chenqiuyan/XX-Net
    win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
    sys.path.append(win32_lib)
elif sys.platform.startswith("linux"):
    linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
    sys.path.append(linux_lib)
elif sys.platform == "darwin":
    darwin_lib = os.path.abspath( os.path.join(python_path, 'lib', 'darwin'))
    sys.path.append(darwin_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    sys.path.append(extra_lib)



from front import front
from xlog import getLogger
xlog = getLogger("heroku_front")
xlog.set_buffer(2000)


def get():
    start_time = time.time()
    content, status, response = front.request("GET", "dns.xx-net.net", path="/query?domain=www.google.com")
    time_cost = time.time() - start_time
    xlog.info("GET cost:%f", time_cost)
    xlog.info("status:%d content:%s", status, content)
    front.stop()


if __name__ == '__main__':
    import traceback
コード例 #17
0
import os

import xlog
logger = xlog.getLogger("cloudfront_front")
logger.set_buffer(500)

from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.ip_manager import IpManager
from front_base.ip_source import Ipv4RangeSource
from front_base.http_dispatcher import HttpsDispatcher
from front_base.connect_manager import ConnectManager
from front_base.check_ip import CheckIp

from config import Config
import host_manager
from gae_proxy.local import check_local_network

current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(
    os.path.join(current_path, os.pardir, os.pardir, os.pardir))
data_path = os.path.abspath(
    os.path.join(root_path, os.pardir, os.pardir, 'data'))
module_data_path = os.path.join(data_path, 'x_tunnel')


class Front(object):
    name = "cloudfront_front"

    def __init__(self):
        self.running = True
コード例 #18
0
ファイル: check_ip.py プロジェクト: chenqiuyan/XX-Net
if sys.platform == "win32":
    win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
    sys.path.append(win32_lib)
elif sys.platform.startswith("linux"):
    linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
    sys.path.append(linux_lib)
elif sys.platform == "darwin":
    darwin_lib = os.path.abspath( os.path.join(python_path, 'lib', 'darwin'))
    sys.path.append(darwin_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    sys.path.append(extra_lib)


import xlog
logger = xlog.getLogger("check_ip")
logger.set_buffer(500)

from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.check_ip import CheckIp


from config import Config


if __name__ == "__main__":
    # case 1: only ip
    # case 2: ip + domain
    #    connect use domain
コード例 #19
0
import os

current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
data_path = os.path.abspath(
    os.path.join(root_path, os.pardir, os.pardir, 'data', "smart_router"))

import utils
from xlog import getLogger

xlog = getLogger("smart_router")


class Config(object):
    rule_list = ["direct", "gae", "socks", "black", "redirect_https"]

    def __init__(self):
        self.rule_lists = {}
        self.host_rules = {}
        self.end_rules = {}

        self.redirect_https_host_rules = ()
        self.redirect_https_end_rules = ()

        self.load()

    def save(self, rules_info):
        for section in self.rule_list:
            if section not in rules_info:
                continue
コード例 #20
0
ファイル: test.py プロジェクト: Suwmlee/XX-Net
if sys.platform == "win32":
    win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
    sys.path.append(win32_lib)
elif sys.platform.startswith("linux"):
    linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
    sys.path.append(linux_lib)
elif sys.platform == "darwin":
    darwin_lib = os.path.abspath( os.path.join(python_path, 'lib', 'darwin'))
    sys.path.append(darwin_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    sys.path.append(extra_lib)


from front import front
from xlog import getLogger
xlog = getLogger("cloudfront_front")
xlog.set_buffer(2000)


def get():
    start_time = time.time()

    content, status, response = front.request("GET", "scan1.xx-net.net", "/", timeout=10)
    #content, status, response = front.request("GET", "dns.xx-net.net", path="/query?domain=www.google.com")

    if isinstance(content, memoryview):
        content = content.tobytes()

    time_cost = time.time() - start_time
    xlog.info("GET cost:%f", time_cost)
    xlog.info("status:%d content:%s", status, content)
コード例 #21
0
import os

import xlog
logger = xlog.getLogger("gae_proxy")
logger.set_buffer(500)

from . import check_local_network

from config import config
from . import host_manager
from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.ip_manager import IpManager
from front_base.ip_source import Ipv4RangeSource, Ipv6PoolSource, IpCombineSource
from front_base.http_dispatcher import HttpsDispatcher
from front_base.connect_manager import ConnectManager
# from .check_ip import CheckIp

from .appid_manager import AppidManager

current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
data_path = os.path.abspath(os.path.join(root_path, os.pardir, os.pardir, 'data'))
module_data_path = os.path.join(data_path, 'gae_proxy')


class Front(object):
    name = "gae_front"

    def __init__(self):
        self.logger = logger
コード例 #22
0
ファイル: proxy_session.py プロジェクト: zhengpu1/XX-Net
import time
import json
import threading
import struct
import urlparse

from xlog import getLogger
xlog = getLogger("x_tunnel")

from simple_http_client import HTTP_client
import utils
import base_container
import encrypt
import global_var as g


def encrypt_data(data):
    if g.config.encrypt_data:
        return encrypt.Encryptor(g.config.encrypt_password, g.config.encrypt_method).encrypt(data)
    else:
        return data


def decrypt_data(data):
    if g.config.encrypt_data:
        return encrypt.Encryptor(g.config.encrypt_password, g.config.encrypt_method).decrypt(data)
    else:
        return data


class ProxySession():
コード例 #23
0
if __name__ == "__main__":
    default_path = os.path.abspath(os.path.join(current_path, os.pardir))
    noarch_lib = os.path.abspath(os.path.join(default_path, 'lib', 'noarch'))
    sys.path.append(noarch_lib)
    osx_lib = os.path.join(default_path, 'lib', 'darwin')
    sys.path.append(osx_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/3.8/Extras/lib/python/PyObjC"
    sys.path.append(extra_lib)

from config import config, app_name
import module_init
import subprocess
import webbrowser

from xlog import getLogger
xlog = getLogger("launcher")

import AppKit
import SystemConfiguration
from PyObjCTools import AppHelper


class MacTrayObject(AppKit.NSObject):
    def __init__(self):
        pass

    def applicationDidFinishLaunching_(self, notification):
        setupHelper()
        loadConfig()
        self.setupUI()
        self.registerObserver()
コード例 #24
0
import os
import struct

import xlog
logger = xlog.getLogger("heroku_front")
logger.set_buffer(500)

import simple_http_client
from config import Config
import host_manager
from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.ip_manager import IpManager
from front_base.http_dispatcher import HttpsDispatcher
from front_base.connect_manager import ConnectManager
from front_base.check_ip import CheckIp
from gae_proxy.local import check_local_network


current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir, os.pardir))
data_path = os.path.abspath(os.path.join(root_path, os.pardir, os.pardir, 'data'))
module_data_path = os.path.join(data_path, 'x_tunnel')


class Front(object):
    name = "heroku_front"

    def __init__(self):
        self.logger = logger
        config_path = os.path.join(module_data_path, "heroku_front.json")
コード例 #25
0
ファイル: check_ip.py プロジェクト: zsmhub/XX-Net
    python_path = os.path.join(root, 'python27', '1.0')

    noarch_lib = os.path.abspath( os.path.join(python_path, 'lib', 'noarch'))
    #sys.path.insert(0, noarch_lib)
    sys.path.append(noarch_lib)

    if sys.platform == "win32":
        win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
        sys.path.append(win32_lib)
    elif sys.platform.startswith("linux"):
        linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
        #sys.path.insert(0, linux_lib)
        sys.path.append(linux_lib)

    from xlog import getLogger
    xlog = getLogger("cloudflare_front")


else:
    class xlog():
        @staticmethod
        def debug(fmt, *args, **kwargs):
            pass
        @staticmethod
        def info(fmt, *args, **kwargs):
            pass
        @staticmethod
        def warn(fmt, *args, **kwargs):
            pass
        @staticmethod
        def exception(fmt, *args, **kwargs):
コード例 #26
0
ファイル: smart_route.py プロジェクト: zlsun/XX-Net
import time
import socket
import struct
import urlparse
import io
import ssl

import utils
import simple_http_server
from socket_wrap import SocketWrap
import global_var as g
import socks

from xlog import getLogger
xlog = getLogger("smart_router")


SO_ORIGINAL_DST = 80



fake_host = ""


class ConnectFail(Exception):
    pass


class RedirectHttpsFail(Exception):
    pass
コード例 #27
0
import time
import struct
import zlib
import random

from xlog import getLogger
xlog = getLogger("heroku_front")
xlog.set_buffer(500)

import simple_http_client
import http_dispatcher
import connect_control


def inflate(data):
    return zlib.decompress(data, -zlib.MAX_WBITS)


def deflate(data):
    return zlib.compress(data)[2:-4]


class Front(object):
    name = "heroku_front"

    def __init__(self):
        self.hosts = ["xxnet10.herokuapp.com"]
        self.host = str(random.choice(self.hosts))

        self.dispatcher = http_dispatcher.HttpsDispatcher(self.host)
        self.last_success_time = time.time()
コード例 #28
0
ファイル: check_ip.py プロジェクト: CyrusYzGTt/XX-Net
    if sys.platform == "win32":
        win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
        sys.path.append(win32_lib)
    elif sys.platform.startswith("linux"):
        linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
        sys.path.append(linux_lib)
    elif sys.platform == "darwin":
        darwin_lib = os.path.abspath( os.path.join(python_path, 'lib', 'darwin'))
        sys.path.append(darwin_lib)
        extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
        sys.path.append(extra_lib)


import xlog
logger = xlog.getLogger("gae_proxy")

from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.host_manager import HostManagerBase
import front_base.check_ip
from config import config


class CheckIp(front_base.check_ip.CheckIp):
    def check_response(self, response):
        server_type = response.headers.get('Server', "")
        self.logger.debug("status:%d", response.status)
        self.logger.debug("Server type:%s", server_type)

        if response.status not in self.config.check_ip_accept_status:
コード例 #29
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Based on checkgoogleip by  <*****@*****.**>
import random
import time
import os
import ip_utils
from config import config

from xlog import getLogger
xlog = getLogger("gae_proxy")

random.seed(time.time() * 1000000)

current_path = os.path.dirname(os.path.abspath(__file__))


class IpRange(object):
    def __init__(self):
        self.default_range_file = os.path.join(current_path, "ip_range.txt")
        self.user_range_file = os.path.join(config.DATA_PATH, "ip_range.txt")
        self.load_ip_range()

    def load_range_content(self):

        if os.path.isfile(self.user_range_file):
            self.range_file = self.user_range_file
        else:
            self.range_file = self.default_range_file

        xlog.info("load ip range file:%s", self.range_file)
コード例 #30
0
ファイル: start.py プロジェクト: DMJackZ/XX-Net
    if not os.path.isdir(data_path):
        os.mkdir(data_path)

    if not os.path.isdir(data_launcher_path):
        os.mkdir(data_launcher_path)

    data_gae_proxy_path = os.path.join(data_path, 'gae_proxy')
    if not os.path.isdir(data_gae_proxy_path):
        os.mkdir(data_gae_proxy_path)

create_data_path()


from xlog import getLogger
log_file = os.path.join(data_launcher_path, "launcher.log")
xlog = getLogger("launcher", file_name=log_file)


def uncaughtExceptionHandler(type_, value, traceback):
    if type == KeyboardInterrupt:  # Ctrl + C on console
        xlog.warn("KeyboardInterrupt, exiting...")
        module_init.stop_all()
        os._exit(0)

    print("uncaught Exception:", type_, value, traceback)
    with open(os.path.join(data_launcher_path, "error.log"), "a") as fd:
        now = datetime.now()
        time_str = now.strftime("%b %d %H:%M:%S.%f")[:19]
        fd.write("%s type:%s value=%s traceback:%s" % (time_str, type_, value, traceback))
    xlog.error("uncaught Exception, type=%s value=%s traceback:%s", type_, value, traceback)
    # sys.exit(1)
コード例 #31
0
import os
import urlparse
import datetime
import threading
import mimetools
import socket
import errno
import sys
import select
import time
import json


import xlog
logging = xlog.getLogger("simple_http_server")


class HttpServerHandler():
    default_request_version = "HTTP/1.1"
    MessageClass = mimetools.Message
    rbufsize = -1
    wbufsize = 0

    def __init__(self, sock, client, args):
        self.connection = sock
        self.rfile = socket._fileobject(self.connection, "rb", self.rbufsize)
        self.wfile = socket._fileobject(self.connection, "wb", self.wbufsize)
        self.client_address = client
        self.args = args
        self.setup()
コード例 #32
0
ファイル: gae_front.py プロジェクト: Suwmlee/XX-Net
import os
import sys

from xlog import getLogger
xlog = getLogger("x_tunnel")

current_path = os.path.dirname(os.path.abspath(__file__))
launcher_path = os.path.abspath( os.path.join(current_path, os.pardir, os.pardir, "launcher"))
if launcher_path not in sys.path:
    sys.path.append(launcher_path)

try:
    from module_init import proc_handler
except:
    xlog.info("launcher not running")
    proc_handler = None

name = "gae_front"
gae_proxy = None


def init():
    global gae_proxy
    if not proc_handler:
        return False

    if "gae_proxy" not in proc_handler:
        xlog.debug("gae_proxy not running")
        return False

    gae_proxy = proc_handler["gae_proxy"]["imp"].local
コード例 #33
0
ファイル: check_ip.py プロジェクト: Suwmlee/XX-Net
if sys.platform == "win32":
    win32_lib = os.path.abspath( os.path.join(python_path, 'lib', 'win32'))
    sys.path.append(win32_lib)
elif sys.platform.startswith("linux"):
    linux_lib = os.path.abspath( os.path.join(python_path, 'lib', 'linux'))
    sys.path.append(linux_lib)
elif sys.platform == "darwin":
    darwin_lib = os.path.abspath( os.path.join(python_path, 'lib', 'darwin'))
    sys.path.append(darwin_lib)
    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    sys.path.append(extra_lib)



import xlog
logger = xlog.getLogger("tls_relay")
logger.set_buffer(500)

from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.check_ip import CheckIp


from config import Config


if __name__ == "__main__":
    # case 1: only ip
    # case 2: ip + domain
    #    connect use domain
コード例 #34
0
ファイル: gae_handler.py プロジェクト: GitHublong/XX-Net
import struct
import zlib
import functools
import re
import io
import string
import socket
import ssl
import httplib
import Queue
import urlparse
import threading


from xlog import getLogger
xlog = getLogger("gae_proxy")
from connect_manager import https_manager
from appids_manager import appid_manager


import OpenSSL
NetWorkIOError = (socket.error, ssl.SSLError, OpenSSL.SSL.Error, OSError)

from config import config
from google_ip import google_ip

def generate_message_html(title, banner, detail=''):
    MESSAGE_TEMPLATE = '''
    <html><head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <title>$title</title>
コード例 #35
0
import os
import struct

import xlog
logger = xlog.getLogger("heroku_front")
logger.set_buffer(500)

import simple_http_client
from config import Config
import host_manager
from front_base.openssl_wrap import SSLContext
from front_base.connect_creator import ConnectCreator
from front_base.ip_manager import IpManager
from front_base.http_dispatcher import HttpsDispatcher
from front_base.connect_manager import ConnectManager
from front_base.check_ip import CheckIp
from gae_proxy.local import check_local_network

current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(
    os.path.join(current_path, os.pardir, os.pardir, os.pardir))
data_path = os.path.abspath(
    os.path.join(root_path, os.pardir, os.pardir, 'data'))
module_data_path = os.path.join(data_path, 'x_tunnel')


class Front(object):
    name = "heroku_front"

    def __init__(self):
        self.logger = logger