# Path: ss/wrapper.py
# def onstart(func):
#     onstart_callbacks.append(func)
#     return func
# 
# Path: ss/settings.py
# class Settings(object):
#     DEFAULT_TIMEOUT = 300
#     _LOCK = RLock()
#     def __init__(self):
#     def __getitem__(self, name):
#     def __setitem__(self, name, val):
#     def get(self, name, default=None):
#     def __contains__(self, name):
#     def update(self, config):
#     def dict(self):
#     def __repr__(self):


import re
import time
import logging
from ss.wrapper import onstart
from ss.settings import settings
# -*- coding: utf-8 -*-

class ProxyAutoConfig(object):

    content = ""
    URI = "/pac?t="

    def __str__(self):
        s = "HTTP/1.1 200 OK\r\n"\
        "Server: myss\r\n"\
        "Connection: Close\r\n"\
        "Content-Type: application/x-ns-proxy-autoconfig\r\n"\
        "Content-Length: %d\r\n"\
        "\r\n"\
        "%s\r\n" % (len(self.content), self.content)
        return s

    @classmethod
    def load(cls):
        path = settings["pac"]
        with open(path, "r") as f:
            data = f.read()
        host = settings["local_address"]

# Path: ss/wrapper.py
# def onstart(func):
#     onstart_callbacks.append(func)
#     return func
# 
# Path: ss/settings.py
# class Settings(object):
#     DEFAULT_TIMEOUT = 300
#     _LOCK = RLock()
#     def __init__(self):
#     def __getitem__(self, name):
#     def __setitem__(self, name, val):
#     def get(self, name, default=None):
#     def __contains__(self, name):
#     def update(self, config):
#     def dict(self):
#     def __repr__(self):


# Path: ss/core/pac.py
import re
import time
import logging
from ss.wrapper import onstart
from ss.settings import settings

# -*- coding: utf-8 -*-

class ProxyAutoConfig(object):

    content = ""
    URI = "/pac?t="

    def __str__(self):
        s = "HTTP/1.1 200 OK\r\n"\
        "Server: myss\r\n"\
        "Connection: Close\r\n"\
        "Content-Type: application/x-ns-proxy-autoconfig\r\n"\
        "Content-Length: %d\r\n"\
        "\r\n"\
        "%s\r\n" % (len(self.content), self.content)
        return s

    @classmethod
    def load(cls):
        path = settings["pac"]
        with open(path, "r") as f:
            data = f.read()
        host = settings["local_address"]

        socks5_port = settings.get("local_port", 1080)