stp-server


Namestp-server JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummarySTP: Sitty Talky messaging Protocol : A primitive protocol purely written in python for tinkering with your office mates over LAN!
upload_time2024-04-18 01:56:07
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT License Copyright (c) 2024 Agraj P Das Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords stp sitty-talky sittytalky lan messaging protocol
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # STP : Sitty Talky Protocol
⚠️ **Work In Progress**

⚠️ Beware of the buzzword: Spanig Tree Protocol. The STP described over here is much more stupid..

**STP: Sitty Talky messaging Protocol** : A primitive protocol purely written in python for tinkering with your office mates over LAN! Originally created for my side project [Sitty Talky](https://github.com/bruttaZz/sittytalky).

[![pypi](https://img.shields.io/pypi/v/stp-server.svg)](https://pypi.org/project/stp-server/)
[![Release](https://img.shields.io/github/release/bruttazz/stp.svg)](https://github.com/bruttazz/stp/releases/latest)


---

### STP uses and have

- uses UDP for peer finding and broadcasting (actually it's multicasting (used to reduce trafic (as part of being a good citizon)))
- uses TCP for peer to peer connection (usual things)
- A unique peer discovery mechanism (may not be perfect though)
- An end-to-end encrypted peer to peer messaging facility by default (I mean real end-to-end)
- Good news: there is no threads being spawned, the system can be added to your existing python eventloop (if needed)


### Requirements
- **Python version >= 3.11** (As it currently uses `loop.sock_recvfrom` in `asyncio`, Otherwise should go with the `loop.run_in_executor`, which I am not interested on)

- Internally uses **[Pycryptodome](https://pypi.org/project/pycryptodome/)** for rsa encryption.
- **The system is tested only on Unix (GNU/Linux to be specific)**

### Installation
This package can be installed from PyPi using
```sh
pip install stp-server
```

Or directly from github using 
```sh
pip install 'stp-server @ git+https://github.com/bRuttaZz/stp.git'
```


### Usage
**A simple use case is demonstated bellow**

starting the server
```py
from stp import STPServer
from stp.interfaces import Packet, Peer

app = STPServer()

@app.route("/test-route")
def test_route_func(packet:Packet):
    print(f"Message got from {packet.headers.user}@{packet.sender} : {packet.data}")

# bind events
@app.on_peer_list_update
def peer_list_change(new_peer:Peer, removed_peers:list[Peer]):
    print(f"Peer list changed : new peer -> {new_peer.user}@{new_peer.ip}" +
                f" : removed peers -> {len(removed_peers)}")
    
if __name__=="__main__":
    print(f"starting server ...")
    app.run()
```

sending messages to the client over a LAN network
```py
from stp import STPServer

app = STPServer()
    
if __name__=="__main__":
    app.broadcast("/test-route", "hi dear")
    # app.send_to_peer() # work only if peers are discovered (uses TCP)
```

### The module architecture

<img src="./.assets/stp.excalidraw.svg">



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "stp-server",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "stp, sitty-talky, sittytalky, LAN, Messaging, protocol",
    "author": null,
    "author_email": "\"@bRuttaZz\" <agrajpdasprivate@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/24/b3/e44cad4acf195112c88fc73b863a5829d60fb9aa43aac42a84e567298360/stp_server-0.1.2.tar.gz",
    "platform": null,
    "description": "# STP : Sitty Talky Protocol\n\u26a0\ufe0f **Work In Progress**\n\n\u26a0\ufe0f Beware of the buzzword: Spanig Tree Protocol. The STP described over here is much more stupid..\n\n**STP: Sitty Talky messaging Protocol** : A primitive protocol purely written in python for tinkering with your office mates over LAN! Originally created for my side project [Sitty Talky](https://github.com/bruttaZz/sittytalky).\n\n[![pypi](https://img.shields.io/pypi/v/stp-server.svg)](https://pypi.org/project/stp-server/)\n[![Release](https://img.shields.io/github/release/bruttazz/stp.svg)](https://github.com/bruttazz/stp/releases/latest)\n\n\n---\n\n### STP uses and have\n\n- uses UDP for peer finding and broadcasting (actually it's multicasting (used to reduce trafic (as part of being a good citizon)))\n- uses TCP for peer to peer connection (usual things)\n- A unique peer discovery mechanism (may not be perfect though)\n- An end-to-end encrypted peer to peer messaging facility by default (I mean real end-to-end)\n- Good news: there is no threads being spawned, the system can be added to your existing python eventloop (if needed)\n\n\n### Requirements\n- **Python version >= 3.11** (As it currently uses `loop.sock_recvfrom` in `asyncio`, Otherwise should go with the `loop.run_in_executor`, which I am not interested on)\n\n- Internally uses **[Pycryptodome](https://pypi.org/project/pycryptodome/)** for rsa encryption.\n- **The system is tested only on Unix (GNU/Linux to be specific)**\n\n### Installation\nThis package can be installed from PyPi using\n```sh\npip install stp-server\n```\n\nOr directly from github using \n```sh\npip install 'stp-server @ git+https://github.com/bRuttaZz/stp.git'\n```\n\n\n### Usage\n**A simple use case is demonstated bellow**\n\nstarting the server\n```py\nfrom stp import STPServer\nfrom stp.interfaces import Packet, Peer\n\napp = STPServer()\n\n@app.route(\"/test-route\")\ndef test_route_func(packet:Packet):\n    print(f\"Message got from {packet.headers.user}@{packet.sender} : {packet.data}\")\n\n# bind events\n@app.on_peer_list_update\ndef peer_list_change(new_peer:Peer, removed_peers:list[Peer]):\n    print(f\"Peer list changed : new peer -> {new_peer.user}@{new_peer.ip}\" +\n                f\" : removed peers -> {len(removed_peers)}\")\n    \nif __name__==\"__main__\":\n    print(f\"starting server ...\")\n    app.run()\n```\n\nsending messages to the client over a LAN network\n```py\nfrom stp import STPServer\n\napp = STPServer()\n    \nif __name__==\"__main__\":\n    app.broadcast(\"/test-route\", \"hi dear\")\n    # app.send_to_peer() # work only if peers are discovered (uses TCP)\n```\n\n### The module architecture\n\n<img src=\"./.assets/stp.excalidraw.svg\">\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Agraj P Das  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "STP: Sitty Talky messaging Protocol : A primitive protocol purely written in python for tinkering with your office mates over LAN!",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/bRuttaZz/stp",
        "Issues": "https://github.com/bRuttaZz/stp/issues",
        "Repository": "https://github.com/bRuttaZz/stp.git"
    },
    "split_keywords": [
        "stp",
        " sitty-talky",
        " sittytalky",
        " lan",
        " messaging",
        " protocol"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97c30037c0dc68133cf7f97847dd02a93ed59afa91f186d0c14d24184a692970",
                "md5": "66ff1c3d0306f167046fa67d5f367959",
                "sha256": "376e5a9370eee2ec84b04c30c29a3209741ee34491d72ad3434cbdb2d0804621"
            },
            "downloads": -1,
            "filename": "stp_server-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "66ff1c3d0306f167046fa67d5f367959",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 17266,
            "upload_time": "2024-04-18T01:56:05",
            "upload_time_iso_8601": "2024-04-18T01:56:05.655328Z",
            "url": "https://files.pythonhosted.org/packages/97/c3/0037c0dc68133cf7f97847dd02a93ed59afa91f186d0c14d24184a692970/stp_server-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24b3e44cad4acf195112c88fc73b863a5829d60fb9aa43aac42a84e567298360",
                "md5": "fe33c0d7c7e8dc755b86b12044e43687",
                "sha256": "c2d269bdcb84b727aafe47be3f31a43fadbb7f2ddb17b49cf68336830b97854e"
            },
            "downloads": -1,
            "filename": "stp_server-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "fe33c0d7c7e8dc755b86b12044e43687",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 83181,
            "upload_time": "2024-04-18T01:56:07",
            "upload_time_iso_8601": "2024-04-18T01:56:07.651542Z",
            "url": "https://files.pythonhosted.org/packages/24/b3/e44cad4acf195112c88fc73b863a5829d60fb9aa43aac42a84e567298360/stp_server-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-18 01:56:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bRuttaZz",
    "github_project": "stp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "stp-server"
}
        
Elapsed time: 0.24447s