{ "info": { "author": "tw7613781", "author_email": "tw7613781@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# ssdp_upnp\n\n## Introduction \nThe acticle [Exploring UPnP with Python](https://www.electricmonk.nl/log/2016/07/05/exploring-upnp-with-python/) gives a realy good insight of UPNP. SSDP is one of it's implementation.\n\nThe packege includes **three individual Classes**, ssdp server, ssdp client, nat upnp class. They first two class inherits from Class threading.Thread class, thus the two class instance runs on a single thread of own. They will not block main thread. After the ssdp client find a peer with same product name, it can communicate with main thread by **queue**. Nat upnp class is running on main thread, thus it will not block I/O, it will just search for LAN GDI (router with upnp nap forwarding function), and bind internal port with external port.\n\nThe logic of server is just listen a broadcast address with port 1900. If it received a \"M-SEARCH\" message, it will responce it's service infomation. The client just send a broadcast message with \"M-SEARCH\", and get server's service infomation.\n\nThe package can be used in blockchain solution where peers to find each other in LAN environment. \n\n\n## API \n\n### Server Class\n\n**run()**: run the server in main thread with I/O blocking \n**start()**: run the server in other thread with I/O nonblocking \n**stop()**: stop the server \n\n### Client\n\n**run()**: run the client in main thread with I/O blocking \n**start()**: run the client in other thread with I/O nonblocking \n**stop()**: stop the client \n\n### Nat \n**addPortForward(internal_port, external_port)**: run the function in main thread. It returns None if fail to bind, returns a tuple (external_ip, external_port) if succeed. \n**removePortForward(external_port)**: run the function in main thread. It returns True if succeed, and returns False if failed. \n\n\n## example\n```\npip install ssdp-upnp\n```\n```\n import sys\n from ssdp_upnp.ssdp import Server, Client, Nat\n from ssdp_upnp.ssdp import gen_logger\n from queue import Queue\n\n logger = gen_logger('sample')\n\n if __name__ == '__main__':\n try:\n if sys.argv[1] == 'server':\n upnpServer = Server(8048, 'blockchain', 'main')\n upnpServer.start()\n elif sys.argv[1] == 'client':\n queue = Queue()\n upnpClient = Client('blockchain', 'main', queue)\n upnpClient.start()\n logger.info(queue.get())\n elif sys.argv[1] == 'nat':\n nat = Nat()\n print(nat.addPortForward(8011, 8015))\n else:\n logger.warning('need params server or clinet')\n except Exception as e:\n logger.error(e)\n```\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tw7613781/ssdp_upnp", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "ssdp-upnp", "package_url": "https://pypi.org/project/ssdp-upnp/", "platform": "", "project_url": "https://pypi.org/project/ssdp-upnp/", "project_urls": { "Homepage": "https://github.com/tw7613781/ssdp_upnp" }, "release_url": "https://pypi.org/project/ssdp-upnp/0.1.0/", "requires_dist": [ "colorlog (>=3.1.4)", "miniupnpc (>=2.0.2)" ], "requires_python": "", "summary": "ssdp server and client of upnp", "version": "0.1.0" }, "last_serial": 4532003, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "8085b80c573ee71d0545fe203f108b41", "sha256": "c23c71773dbc6a4deb5af140ed6ea7fbece567f2dc9fac2808a263d7f44c7eca" }, "downloads": -1, "filename": "ssdp_upnp-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8085b80c573ee71d0545fe203f108b41", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5004, "upload_time": "2018-11-23T16:46:45", "url": "https://files.pythonhosted.org/packages/23/8f/6f27503cf4c05115b98b52c28114d3271b641340c076e8a1a841d38a405b/ssdp_upnp-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f3d1700156c9036c42190ad508e366c8", "sha256": "9e7fe2ab19532d8b0d04c9f36b7d3a765a75c62b7aa10e0bf09672cf5f6b9edd" }, "downloads": -1, "filename": "ssdp_upnp-0.0.1.tar.gz", "has_sig": false, "md5_digest": "f3d1700156c9036c42190ad508e366c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3511, "upload_time": "2018-11-23T16:46:47", "url": "https://files.pythonhosted.org/packages/fb/7e/a063ef585b5477b8bf26d35f81aceeca4f468af381e832e329badb395377/ssdp_upnp-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "8f91a57c8dbb976af102fca4f1c23198", "sha256": "65c905c0457e9ee6ee4ac75dd1704446cf65366e8c3a62b2035e7c003974be65" }, "downloads": -1, "filename": "ssdp_upnp-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "8f91a57c8dbb976af102fca4f1c23198", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5030, "upload_time": "2018-11-23T17:04:52", "url": "https://files.pythonhosted.org/packages/45/5a/63439a74ea8cfc5e74f0a268c2b8228e08c5308630c3d8ce7bdadd336400/ssdp_upnp-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "09bedc3846c39a8ecbf764f68b2e3247", "sha256": "516ee44c12ac1110dd7e2d43d2abf6b4fe35d8d1239c188a7e181186fafa2573" }, "downloads": -1, "filename": "ssdp_upnp-0.0.2.tar.gz", "has_sig": false, "md5_digest": "09bedc3846c39a8ecbf764f68b2e3247", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3563, "upload_time": "2018-11-23T17:04:54", "url": "https://files.pythonhosted.org/packages/25/1f/185c068c71fdc41200814f7e8fba61d7f80d6fd538e65de8c741063ab39e/ssdp_upnp-0.0.2.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "531e4516c034980eaae52fef01f4855d", "sha256": "804b2fd4c8a5b3f9c1e3c114b67154da86096bc04e266bbdaf58eca662f67f2a" }, "downloads": -1, "filename": "ssdp_upnp-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "531e4516c034980eaae52fef01f4855d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5747, "upload_time": "2018-11-27T01:14:44", "url": "https://files.pythonhosted.org/packages/9c/e5/4ee71fdbda73d5161b0af5f39b55475b1ea19d38668a211b9de8198a0550/ssdp_upnp-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "557a1c2a28e54a860c4b9c30978e5278", "sha256": "3d680668a28922b5fbb4f69c5209df147d6dadbc2ecaea65fd8016c8f7db5b28" }, "downloads": -1, "filename": "ssdp_upnp-0.1.0.tar.gz", "has_sig": false, "md5_digest": "557a1c2a28e54a860c4b9c30978e5278", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4368, "upload_time": "2018-11-27T01:14:45", "url": "https://files.pythonhosted.org/packages/55/2a/9af87f5eb75c0db21d6efbab681bf201ff19775995ffa5f67995b6f097a8/ssdp_upnp-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "531e4516c034980eaae52fef01f4855d", "sha256": "804b2fd4c8a5b3f9c1e3c114b67154da86096bc04e266bbdaf58eca662f67f2a" }, "downloads": -1, "filename": "ssdp_upnp-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "531e4516c034980eaae52fef01f4855d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5747, "upload_time": "2018-11-27T01:14:44", "url": "https://files.pythonhosted.org/packages/9c/e5/4ee71fdbda73d5161b0af5f39b55475b1ea19d38668a211b9de8198a0550/ssdp_upnp-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "557a1c2a28e54a860c4b9c30978e5278", "sha256": "3d680668a28922b5fbb4f69c5209df147d6dadbc2ecaea65fd8016c8f7db5b28" }, "downloads": -1, "filename": "ssdp_upnp-0.1.0.tar.gz", "has_sig": false, "md5_digest": "557a1c2a28e54a860c4b9c30978e5278", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4368, "upload_time": "2018-11-27T01:14:45", "url": "https://files.pythonhosted.org/packages/55/2a/9af87f5eb75c0db21d6efbab681bf201ff19775995ffa5f67995b6f097a8/ssdp_upnp-0.1.0.tar.gz" } ] }