{"id":13775856,"url":"https://github.com/pagekite/pysocksipychain","last_synced_at":"2025-04-16T01:09:18.705Z","repository":{"id":2699233,"uuid":"1888964","full_name":"pagekite/PySocksipyChain","owner":"pagekite","description":"Modified socks.py which supports chained proxies","archived":false,"fork":false,"pushed_at":"2025-03-26T12:59:10.000Z","size":120,"stargazers_count":57,"open_issues_count":1,"forks_count":17,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-16T01:06:55.012Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pagekite.net/wiki/Floss/PySocksipyChain/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pagekite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-06-13T14:04:58.000Z","updated_at":"2025-03-26T12:59:03.000Z","dependencies_parsed_at":"2025-04-16T01:06:59.063Z","dependency_job_id":null,"html_url":"https://github.com/pagekite/PySocksipyChain","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pagekite%2FPySocksipyChain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pagekite%2FPySocksipyChain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pagekite%2FPySocksipyChain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pagekite%2FPySocksipyChain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pagekite","download_url":"https://codeload.github.com/pagekite/PySocksipyChain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249178212,"owners_count":21225349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:01:52.633Z","updated_at":"2025-04-16T01:09:18.644Z","avatar_url":"https://github.com/pagekite.png","language":"Python","funding_links":[],"categories":["\u003ca id=\"d03d494700077f6a65092985c06bf8e8\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"57b8e953d394bbed52df2a6976d98dfa\"\u003e\u003c/a\u003eSocks"],"readme":"# PySocksipyChain #\n\nThis is a modified version of socksipy, which supports arbitrary chaining of\nproxy servers and various modes of TLS/SSL encryption.\n\nThis can be used to very easily add proxy and TLS/SSL support to almost any\nPython TCP-based communications, and was initially done to support the needs\nof the [PageKite](http://pagekite.org/) project.\n\nSee [the PySocksipyChain page on\npagekite.net](http://pagekite.net/wiki/Floss/PySocksipyChain/) for further\ndetails.\n\n\n-------------------------------------------------------------------------------\n# Original README #\n\n\u003cpre\u003e\nSocksiPy version 1.00\nA Python SOCKS module.\n(C) 2006 Dan-Haim. All rights reserved.\nSee LICENSE file for details.\n\n\nWHAT IS A SOCKS PROXY?\nA SOCKS proxy is a proxy server at the TCP level. In other words, it acts as\na tunnel, relaying all traffic going through it without modifying it.\nSOCKS proxies can be used to relay traffic using any network protocol that\nuses TCP.\n\nWHAT IS SOCKSIPY?\nThis Python module allows you to create TCP connections through a SOCKS\nproxy without any special effort.\n\nPROXY COMPATIBILITY\nSocksiPy is compatible with three different types of proxies:\n1. SOCKS Version 4 (Socks4), including the Socks4a extension.\n2. SOCKS Version 5 (Socks5).\n3. HTTP Proxies which support tunneling using the CONNECT method.\n\nSYSTEM REQUIREMENTS\nBeing written in Python, SocksiPy can run on any platform that has a Python\ninterpreter and TCP/IP support.\nThis module has been tested with Python 2.3 and should work with greater versions\njust as well.\n\n\nINSTALLATION\n-------------\n\nSimply copy the file \"socks.py\" to your Python's lib/site-packages directory,\nand you're ready to go.\n\n\nUSAGE\n------\n\nFirst load the socks module with the command:\n\n\u003e\u003e\u003e import socks\n\u003e\u003e\u003e\n\nThe socks module provides a class called \"socksocket\", which is the base to\nall of the module's functionality.\nThe socksocket object has the same initialization parameters as the normal socket\nobject to ensure maximal compatibility, however it should be noted that socksocket\nwill only function with family being AF_INET and type being SOCK_STREAM.\nGenerally, it is best to initialize the socksocket object with no parameters\n\n\u003e\u003e\u003e s = socks.socksocket()\n\u003e\u003e\u003e\n\nThe socksocket object has an interface which is very similar  to socket's (in fact\nthe socksocket class is derived from socket) with a few extra methods.\nTo select the proxy server you would like to use, use the setproxy method, whose\nsyntax is:\n\nsetproxy(proxytype, addr[, port[, rdns[, username[, password]]]])\n\nExplaination of the parameters:\n\nproxytype - The type of the proxy server. This can be one of three possible\nchoices: PROXY_TYPE_SOCKS4, PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP for Socks4,\nSocks5 and HTTP servers respectively.\n\naddr - The IP address or DNS name of the proxy server.\n\nport - The port of the proxy server. Defaults to 1080 for socks and 8080 for http.\n\nrdns - This is a boolean flag than modifies the behavior regarding DNS resolving.\nIf it is set to True, DNS resolving will be preformed remotely, on the server.\nIf it is set to False, DNS resolving will be preformed locally. Please note that\nsetting this to True with Socks4 servers actually use an extension to the protocol,\ncalled Socks4a, which may not be supported on all servers (Socks5 and http servers\nalways support DNS). The default is True.\n\nusername - For Socks5 servers, this allows simple username / password authentication\nwith the server. For Socks4 servers, this parameter will be sent as the userid.\nThis parameter is ignored if an HTTP server is being used. If it is not provided,\nauthentication will not be used (servers may accept unauthentication requests).\n\npassword - This parameter is valid only for Socks5 servers and specifies the\nrespective password for the username provided.\n\nExample of usage:\n\n\u003e\u003e\u003e s.setproxy(socks.PROXY_TYPE_SOCKS5,\"socks.example.com\")\n\u003e\u003e\u003e\n\nAfter the setproxy method has been called, simply call the connect method with the\ntraditional parameters to establish a connection through the proxy:\n\n\u003e\u003e\u003e s.connect((\"www.sourceforge.net\",80))\n\u003e\u003e\u003e\n\nConnection will take a bit longer to allow negotiation with the proxy server.\nPlease note that calling connect without calling setproxy earlier will connect\nwithout a proxy (just like a regular socket).\n\nErrors: Any errors in the connection process will trigger exceptions. The exception\nmay either be generated by the underlying socket layer or may be custom module\nexceptions, whose details follow:\n\nclass ProxyError - This is a base exception class. It is not raised directly but\nrather all other exception classes raised by this module are derived from it.\nThis allows an easy way to catch all proxy-related errors.\n\nclass GeneralProxyError - When thrown, it indicates a problem which does not fall\ninto another category. The parameter is a tuple containing an error code and a\ndescription of the error, from the following list:\n1 - invalid data - This error means that unexpected data has been received from\nthe server. The most common reason is that the server specified as the proxy is\nnot really a Socks4/Socks5/HTTP proxy, or maybe the proxy type specified is wrong.\n4 - bad proxy type - This will be raised if the type of the proxy supplied to the\nsetproxy function was not PROXY_TYPE_SOCKS4/PROXY_TYPE_SOCKS5/PROXY_TYPE_HTTP.\n5 - bad input - This will be raised if the connect method is called with bad input\nparameters.\n\nclass Socks5AuthError - This indicates that the connection through a Socks5 server\nfailed due to an authentication problem. The parameter is a tuple containing a\ncode and a description message according to the following list:\n\n1 - authentication is required - This will happen if you use a Socks5 server which\nrequires authentication without providing a username / password at all.\n2 - all offered authentication methods were rejected - This will happen if the proxy\nrequires a special authentication method which is not supported by this module.\n3 - unknown username or invalid password - Self descriptive.\n\nclass Socks5Error - This will be raised for Socks5 errors which are not related to\nauthentication. The parameter is a tuple containing a code and a description of the\nerror, as given by the server. The possible errors, according to the RFC are:\n\n1 - General SOCKS server failure - If for any reason the proxy server is unable to\nfulfill your request (internal server error).\n2 - connection not allowed by ruleset - If the address you're trying to connect to\nis blacklisted on the server or requires authentication.\n3 - Network unreachable - The target could not be contacted. A router on the network\nhad replied with a destination net unreachable error.\n4 - Host unreachable - The target could not be contacted. A router on the network\nhad replied with a destination host unreachable error.\n5 - Connection refused - The target server has actively refused the connection\n(the requested port is closed).\n6 - TTL expired - The TTL value of the SYN packet from the proxy to the target server\nhas expired. This usually means that there are network problems causing the packet\nto be caught in a router-to-router \"ping-pong\".\n7 - Command not supported - The client has issued an invalid command. When using this\nmodule, this error should not occur.\n8 - Address type not supported - The client has provided an invalid address type.\nWhen using this module, this error should not occur.\n\nclass Socks4Error - This will be raised for Socks4 errors. The parameter is a tuple\ncontaining a code and a description of the error, as given by the server. The\npossible error, according to the specification are:\n\n1 - Request rejected or failed - Will be raised in the event of an failure for any\nreason other then the two mentioned next.\n2 - request rejected because SOCKS server cannot connect to identd on the client -\nThe Socks server had tried an ident lookup on your computer and has failed. In this\ncase you should run an identd server and/or configure your firewall to allow incoming\nconnections to local port 113 from the remote server.\n3 - request rejected because the client program and identd report different user-ids -\nThe Socks server had performed an ident lookup on your computer and has received a\ndifferent userid than the one you have provided. Change your userid (through the\nusername parameter of the setproxy method) to match and try again.\n\nclass HTTPError - This will be raised for HTTP errors. The parameter is a tuple\ncontaining the HTTP status code and the description of the server.\n\n\nAfter establishing the connection, the object behaves like a standard socket.\nCall the close method to close the connection.\n\nIn addition to the socksocket class, an additional function worth mentioning is the\nsetdefaultproxy function. The parameters are the same as the setproxy method.\nThis function will set default proxy settings for newly created socksocket objects,\nin which the proxy settings haven't been changed via the setproxy method.\nThis is quite useful if you wish to force 3rd party modules to use a socks proxy,\nby overriding the socket object.\nFor example:\n\n\u003e\u003e\u003e socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,\"socks.example.com\")\n\u003e\u003e\u003e socket.socket = socks.socksocket\n\u003e\u003e\u003e urllib.urlopen(\"http://www.sourceforge.net/\")\n\n\nPROBLEMS\n---------\n\nIf you have any problems using this module, please first refer to the BUGS file\n(containing current bugs and issues). If your problem is not mentioned you may\ncontact the author at the following E-Mail address:\n\nnegativeiq@users.sourceforge.net\n\nPlease allow some time for your question to be received and handled.\n\n\nDan-Haim,\nAuthor.\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpagekite%2Fpysocksipychain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpagekite%2Fpysocksipychain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpagekite%2Fpysocksipychain/lists"}