# Path: lib/settings.py
# CONF_PATH = os.path.join(ROOT, 'conf/')
# 
# Path: lib/redisopt.py
# def get_hash(host, uri, postdata):
# def content_deal(headers, host, method, postdata, uri, packet):
# 
# Path: lib/config.py
# def load():
# def update(conf):
# def load_rule():
# def update_rule(rule):
# def rule_read(name, get_file_handle=None):
# def rule_write(name, rule):


import re
import ssl
import socket
import warnings
import requests
import threading
from lib.settings import CONF_PATH
from lib.redisopt import conn, content_deal
from lib import config

def client_conn(connstream, https=False):
    try:
        connstream.settimeout(2)
        data = ""
        while True:
            tmp = connstream.recv(10240)
            data += tmp
            if tmp == '':
                break
    except Exception as e:
        pass
    connstream.settimeout(10)
    get_res(data, connstream, https)


def main():
    try:
        addr = config.load()['mix_addr']
        port = int(config.load()['mix_port'])
        bindsocket = socket.socket()
        bindsocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        bindsocket.bind((addr, port))
        bindsocket.listen(300)
    except Exception as e:
        conf = config.load()
        conf['mix_stat'] = "false"
        config.update(conf)
        print e
        exit()

# Path: lib/settings.py
# CONF_PATH = os.path.join(ROOT, 'conf/')
# 
# Path: lib/redisopt.py
# def get_hash(host, uri, postdata):
# def content_deal(headers, host, method, postdata, uri, packet):
# 
# Path: lib/config.py
# def load():
# def update(conf):
# def load_rule():
# def update_rule(rule):
# def rule_read(name, get_file_handle=None):
# def rule_write(name, rule):


# Path: proxy/mix_proxy.py
import re
import ssl
import socket
import warnings
import requests
import threading
from lib.settings import CONF_PATH
from lib.redisopt import conn, content_deal
from lib import config


def client_conn(connstream, https=False):
    try:
        connstream.settimeout(2)
        data = ""
        while True:
            tmp = connstream.recv(10240)
            data += tmp
            if tmp == '':
                break
    except Exception as e:
        pass
    connstream.settimeout(10)
    get_res(data, connstream, https)


def main():
    try:
        addr = config.load()['mix_addr']
        port = int(config.load()['mix_port'])
        bindsocket = socket.socket()
        bindsocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        bindsocket.bind((addr, port))
        bindsocket.listen(300)
    except Exception as e:
        conf = config.load()
        conf['mix_stat'] = "false"
        config.update(conf)
        print e
        exit()

    while config.load()['mix_stat'].lower() == "true":