Ejemplo n.º 1
0
    def convert_proxy(values):
        try:
            _type = values.get("type", "")
            if _type == "http":
                protocol = const.HTTP
            elif _type == "https":
                protocol = const.HTTPS
            else:
                return False, None

            proxy = Proxy(
                values["host"],
                int(values["port"]),
                protocol
            )
        except BaseException:
            return False, None
        else:
            return True, proxy
Ejemplo n.º 2
0
    def start(self):
        print('Server started\n')

        self.input_list.append(self.server_socket)

        while True:
            read_list, _, _ = select.select(self.input_list, [], [])
            for s in read_list:

                if s == self.server_socket:
                    client_socket, client_address = self.server_socket.accept()
                    proxy = Proxy().start(REDIRECT_TO.get('host'),
                                          REDIRECT_TO.get('port'))

                    if proxy:
                        print(
                            f'{client_address[0]}:{client_address[1]} is connected\n'
                        )

                        self.input_list.append(client_socket)
                        self.input_list.append(proxy)

                        self.channel[client_socket] = proxy
                        self.channel[proxy] = client_socket
                    else:
                        print(
                            f'Cannot reach remote server, closing connection with client: {client_address[0]}\n'
                        )
                        client_socket.close()
                    break

                data = s.recv(BUFFER_SIZE)
                if len(data) == 0:
                    self.close(s)
                    break
                else:
                    if self.has_CONNECT(data):
                        self.wrap_with_ssl(s, proxy)

                    print(data)
                    self.channel[s].send(data)
Ejemplo n.º 3
0
Archivo: mcpil.py Proyecto: dw5/MCPIL
current_port: StringVar

# Custom Profile Features
current_features = []
feature_widgets: Dict[str, ttk.Checkbutton] = {}

# Current Process
current_process: Popen = None

# Current Config
current_config = {}

# Proxy
proxy_lock = threading.Lock()
proxy_thread: threading.Thread = None
proxy = Proxy()

'''
    Helper classes.
'''

# Hyper-Link
class HyperLink(ttk.Label):
    def __init__(self, parent, url, text=None, cursor=None, *args, **kwargs):
        self.url = url
        super().__init__(parent, text=(text or url), cursor=(cursor or 'hand2'), *args, **kwargs)
        self.bind('<Button-1>', self.web_open)

    def web_open(self, event):
        return webbrowser.open(self.url)
Ejemplo n.º 4
0
from sneeze.logging import Logger
from proxy.proxy import Proxy

if __name__ == '__main__':
    proxy = Proxy('127.0.0.1', 4949, Logger('sneeze.ini'))
    print('Proxy listening at 127.0.0.1:4949')
    proxy.listen()
Ejemplo n.º 5
0
        high, low, open, close, weighted_average, volume = data
        threshold = 0.01511201
        # Place a sell order when the candlestick average is above a certain
        # threshold.
        if weighted_average > threshold:
            self.new_sell_order()
        # Likewise, place a buy order when the candlestick is below a certain threshold.
        else:
            self.new_buy_order()


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-p",
                        "--proxy",
                        help="instantiate the proxy server",
                        action="store_true")
    parser.add_argument(
        "-d",
        "--dispatch",
        help="dispatch the strategies for execution",
        action="store_true",
    )
    args = parser.parse_args()
    if args.proxy:
        # Instantiate the Proxy.
        Proxy()
    elif args.dispatch:
        # Dispatch a list of strategies.
        Dispatcher([Example1, Example1, Example2])
Ejemplo n.º 6
0
    if optlist[2][1] != '0':  #DIFFERENT PERMUTATION
        help()

if len(args) == 4:
    optlist, args = getopt.getopt(
        args, '',
        ['net-config=', 'firewall-config=', 'log-level=', 'log-file='])

net_config = firewall_config = log_level = log_level = None
for opt in optlist:
    if opt[0] == '--net-config':
        net_config = opt[1]
    elif opt[0] == '--firewall-config':
        firewall_config = opt[1]
    elif opt[0] == '--log-level':
        log_level = int(opt[1])
    elif opt[0] == '--log-file':
        log_file = opt[1]

host, server = parse_net_config(net_config)

#firewall = Firewall(firewall_config, logger)
#proxy = Proxy(host, server, firewall)
#proxy.start()

f_logger = Logger(log_file, log_level, 'firewall')
p_logger = Logger('logs/proxy_log.txt', log_level, 'proxy')
firewall = Firewall(firewall_config, f_logger)
proxy = Proxy(host, server, firewall, p_logger)
proxy.start()
Ejemplo n.º 7
0
                     answers['description'], answers['scheduled_time'])
    handle_menu_selection('List all events')


def handle_event_delete(event):
    proxy.event_delete(event.name)
    handle_menu_selection('List all events')


def handle_event_name_input():
    return prompt(get_event_name_form())


def handle_event_description_input():
    return prompt(get_event_description_form())


if __name__ == "__main__":
    if len(sys.argv) > 1:
        urlServ = sys.argv[1]
    else:
        urlServ = "http://localhost/Xh1Serv.php"

    proxy = Proxy(urlServ)

    print("**********************************************")
    print("***  Welcome to Events Agenda Application  ***")
    print("**********************************************")

    handle_cli_start()
Ejemplo n.º 8
0
 def test_get_proxies(self):
     validator = IPValidator("")
     test_proxy = Proxy('127.0.0.1', 8080, const.HTTP)
     status = validator.check_proxy(test_proxy)
     self.assertTrue(True, status)
Ejemplo n.º 9
0
 def __init__(self, http_log):
     self.proxy = Proxy('127.0.0.1', 4949, http_log)
Ejemplo n.º 10
0
 def convert_proxy(values):
     try:
         return True, Proxy(str(values[0]), int(values[1]), const.HTTP)
     except BaseException:
         return False, None