mirror of https://github.com/dnomd343/ProxyC
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.2 KiB
101 lines
2.2 KiB
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from Basis.Filter import rulesFilter
|
|
from Basis.Functions import isHost, isPort
|
|
from Basis.Functions import toInt, toStr, toStrTidy, toBool
|
|
|
|
secureObject = rulesFilter({
|
|
'verify': {
|
|
'optional': True,
|
|
'default': True,
|
|
'type': bool,
|
|
'format': toBool,
|
|
'errMsg': 'Invalid verify option'
|
|
}
|
|
})
|
|
|
|
originObject = rulesFilter({
|
|
'type': {
|
|
'type': str,
|
|
'format': toStrTidy,
|
|
'filter': lambda s: s == 'origin',
|
|
'errMsg': 'Invalid Origin stream type'
|
|
},
|
|
'uot': {
|
|
'optional': True,
|
|
'default': False,
|
|
'type': bool,
|
|
'format': toBool,
|
|
'errMsg': 'Invalid UoT option'
|
|
}
|
|
})
|
|
|
|
wsObject = rulesFilter({
|
|
'type': {
|
|
'type': str,
|
|
'format': toStrTidy,
|
|
'filter': lambda s: s == 'ws',
|
|
'errMsg': 'Invalid WebSocket stream type'
|
|
},
|
|
'host': {
|
|
'optional': True,
|
|
'default': '',
|
|
'type': str,
|
|
'format': toStrTidy,
|
|
'errMsg': 'Invalid WebSocket host'
|
|
},
|
|
'path': {
|
|
'optional': True,
|
|
'default': '/ws',
|
|
'type': str,
|
|
'format': lambda s: toStr(s).strip(),
|
|
'errMsg': 'Invalid WebSocket path'
|
|
},
|
|
'raw': {
|
|
'optional': True,
|
|
'default': False,
|
|
'type': bool,
|
|
'format': toBool,
|
|
'errMsg': 'Invalid raw option'
|
|
},
|
|
'secure': {
|
|
'optional': True,
|
|
'default': None,
|
|
'allowNone': True,
|
|
'type': secureObject,
|
|
'errMsg': 'Invalid secure options'
|
|
}
|
|
})
|
|
|
|
brookObject = rulesFilter({
|
|
'server': {
|
|
'type': str,
|
|
'format': toStrTidy,
|
|
'filter': isHost,
|
|
'errMsg': 'Invalid server address'
|
|
},
|
|
'port': {
|
|
'type': int,
|
|
'format': toInt,
|
|
'filter': isPort,
|
|
'errMsg': 'Invalid port number'
|
|
},
|
|
'passwd': {
|
|
'type': str,
|
|
'format': toStr,
|
|
'errMsg': 'Invalid password content'
|
|
},
|
|
'stream': {
|
|
'optional': True,
|
|
'default': {
|
|
'type': 'origin'
|
|
},
|
|
'multiSub': True,
|
|
'type': {
|
|
'origin': originObject,
|
|
'ws': wsObject,
|
|
},
|
|
'errMsg': 'Invalid Brook stream'
|
|
}
|
|
})
|
|
|