import platform, os, gzip, urllib.request, json
import yaml

def gen_config(proxy, local_port):
    cfg = {
        "port": 0,
        "socks-port": local_port,
        "mode": "Global",
        "proxies": [{
            "name": proxy["name"],
            "type": "ss",
            "server": proxy["host"],
            "port": proxy["port"],
            "cipher": proxy["method"],
            "password": proxy["password"],
            "plugin": "obfs",
            "plugin-opts": {
                "mode": proxy["obfs"],
                "host": proxy["obfs_host"]
            }
        }],
        "proxy-groups": [{
            "name": "Proxy",
            "type": "select",
            "proxies": [proxy["name"]]
        }],
        "rules": [
            "MATCH,Proxy"
        ]
    }
    return yaml.dump(cfg)

proxy_test = {
    "name": "HK 01",
    "host": "d32b6cd.gylcxo.xyz",
    "port": 18300,
    "method": "aes-128-gcm",
    "password": "ced",
    "obfs": "http",
    "obfs_host": "Sm0lO349ch.microsoft.com"
}
print(gen_config(proxy_test, 10800))
