A python package for creating multi-client server with high level of abstarction, meaning user don't need to write 100s of lines of code. User can write a multi-client server with just 12 lines fo code, it's that simple.
In addition to this PySock also make the connections end-to-end encrypted. It also provide the functionality of creating a end-to-end encrypted connection between two or more client, meaning client can share the data with others client available.
In more simple terms PySock brings to versions of multi-client server. First one is just normal multi-client server with no encryption, user need to write there own wrapper kind fucntion to make it secure if they wants. Other version is highly secure. PySock implements E2E with the help of AES.
The encryption is not just limited to client-server communication but it also encrypts cleint-client communication.
## Below there are two examples listed, first is secure other is unsecure:
---
><h4 style = "color : #7264a3">Sample Secure Server</h4>
Before creating secure version of server make sure you have a .yaml file as it is required
server.py
```python
from PySock import Sserver
def client_msg(data):
print(f"Message From : {data['sender_name']} => {data['data']}")
s = Sserver(
file = r'server_yml.yaml',
debug = False
)
s.SERVER("localhost",1234,10)
s.CREATE_CHANNEL("test")
new_client = []
while True:
for d in s.varifiedDevices:
if d in s.conClients:
if d not in new_client:
s.SEND(d,"test","Hello From Server")
new_client.append(d)
else:
if d in new_client:
new_client.remove(d)
s.LISTEN("test",client_msg)
```
><h4 style = "color : #7264a3">Sample Secure Clients</h4>
Before creating server make sure you have a .yaml file as it is required
clientOne.py
```python
from PySock import Sclient
name = "shikhar"
def abc(data,con):
print(f"Message from : {data['sender_name']} => {data['data']}")
con.SEND("test","Hello!")
def client_msg(data):
print(f"Message from : {data['sender_name']} => {data['data']}")
c = Sclient(client_name = name, file = r'clientOne_yml.yaml', debug = False)
c.CLIENT("localhost",1234)
c.CREATE_CHANNEL("test")
c.HANDSHAKE(target_name = "swat")
count = 0
while True:
c.LISTEN( channel = "test", function = abc, args = (c,) )
c.LISTEN( channel = "DSP_MSG", function = client_msg)
if count == 0:
if c.check("swat") in c.HS_Devices:
c.SEND_TO_CLIENT(target_name = "swat", data = "Hello, what are you doing.")
count += 1
```
clientTwo.py
```python
from PySock import Sclient
name = "swat"
def abc(data,con):
print(f"Message from : {data['sender_name']} => {data['data']}")
con.SEND("test","What are you doing!")
def client_msg(data,con):
print(f"Message From : {data['sender_name']} => {data['data']}")
con.SEND_TO_CLIENT(target_name = data["sender_name"], data = f"Hello From {name}")
c = Sclient(client_name = name, file = r'clientTwo_yml.yaml', debug = False)
c.CLIENT("localhost",1234)
c.CREATE_CHANNEL("test")
count = 0
while True:
c.LISTEN( channel = "test", function = abc, args = (c,) )
c.LISTEN( channel = "DSP_MSG", function = client_msg, args = (c,))
if count == 0:
if "swat" in c.HS_Devices:
c.SEND_TO_CLIENT(target_name = "swat", data = "Hello, what are you doing.")
count += 1
```
### ===You can add as many client like these===
### Result after running server.py, clientOne.py and clientTwo.py
![Markdown logo](resource/PySock-test.png)
---
---
## Now its time for normal multi-client server and clients:
><h4 style = "color : #7264a3">Sample Server</h4>
server.py
```python
from PySock import server
def client_msg(data):
print(f"Message From : {data['sender_name']} => {data['data']}")
s = server(secure = False,debug = True)
s.SERVER("localhost",8888,10)
s.CREATE_CHANNEL("test")
new_client = []
while True:
for d in s.conClients:
if d not in new_client:
s.SEND(d,"test","Hello From Server")
new_client.append(d)
s.LISTEN("test",client_msg)
```
><h4 style = "color : #7264a3">Sample Clients</h4>
clientOne.py
```python
from PySock import client
name = "shikhar"
def abc(data,con):
print(f"Message from {data['sender_name']} : {data['data']}")
con.SEND("test","Hello!")
c = client(client_name = name, debug = True)
c.CLIENT("localhost",8888)
c.CREATE_CHANNEL("test")
count = 0
while True:
c.LISTEN( channel = "test", function = abc, args = (c,) )
if count == 0:
c.SEND_TO_CLIENT(target_name = "swat", data = "Hello, what are you doing.")
count += 1
```
clientTwo.py
```python
from PySock import client
def abc(data,con):
print(f"Message from {data['sender_name']} : {data['data']}")
con.SEND("test","Hurrah! it's working.")
def client_msg(data):
print(f"Message from : {data['sender_name']} => {data['data']}")
c = client(client_name = "swat", debug = True)
c.CLIENT("localhost",8888)
c.CREATE_CHANNEL("test")
while True:
c.LISTEN( channel = "test", function = abc, args = (c,) )
c.LISTEN( channel = "DSP_MSG", function = client_msg)
```
There is no docs for this library but i'm working on docs, hope it will uploaded soon.
Thanks for visiting
---
Raw data
{
"_id": null,
"home_page": "https://github.com/ShikharY10/PySock",
"name": "PySock",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "socket,tcp,stream,encrypted,E2E,multi-client-server",
"author": "Shikhar Yadav",
"author_email": "<yshikharfzd10@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ae/41/456cc659078957940841eb15783d5a1dc5f7b57fd6708f9798f54f3e3462/PySock-0.3.2.tar.gz",
"platform": "",
"description": "\n\nA python package for creating multi-client server with high level of abstarction, meaning user don't need to write 100s of lines of code. User can write a multi-client server with just 12 lines fo code, it's that simple.\nIn addition to this PySock also make the connections end-to-end encrypted. It also provide the functionality of creating a end-to-end encrypted connection between two or more client, meaning client can share the data with others client available.\n\n\nIn more simple terms PySock brings to versions of multi-client server. First one is just normal multi-client server with no encryption, user need to write there own wrapper kind fucntion to make it secure if they wants. Other version is highly secure. PySock implements E2E with the help of AES.\nThe encryption is not just limited to client-server communication but it also encrypts cleint-client communication.\n\n## Below there are two examples listed, first is secure other is unsecure:\n\n---\n\n><h4 style = \"color : #7264a3\">Sample Secure Server</h4>\n\nBefore creating secure version of server make sure you have a .yaml file as it is required\n\nserver.py\n\n```python\nfrom PySock import Sserver\n\ndef client_msg(data):\n print(f\"Message From : {data['sender_name']} => {data['data']}\")\n\ns = Sserver(\n file = r'server_yml.yaml',\n debug = False\n )\ns.SERVER(\"localhost\",1234,10)\ns.CREATE_CHANNEL(\"test\")\n\nnew_client = []\n\nwhile True:\n for d in s.varifiedDevices:\n if d in s.conClients: \n if d not in new_client:\n s.SEND(d,\"test\",\"Hello From Server\")\n new_client.append(d)\n else:\n if d in new_client:\n new_client.remove(d)\n\n s.LISTEN(\"test\",client_msg)\n```\n\n\n><h4 style = \"color : #7264a3\">Sample Secure Clients</h4>\n\n\nBefore creating server make sure you have a .yaml file as it is required\n\nclientOne.py\n\n```python\nfrom PySock import Sclient\n\nname = \"shikhar\"\n\ndef abc(data,con):\n print(f\"Message from : {data['sender_name']} => {data['data']}\")\n con.SEND(\"test\",\"Hello!\")\n\ndef client_msg(data):\n print(f\"Message from : {data['sender_name']} => {data['data']}\")\n\nc = Sclient(client_name = name, file = r'clientOne_yml.yaml', debug = False)\nc.CLIENT(\"localhost\",1234)\nc.CREATE_CHANNEL(\"test\")\n\nc.HANDSHAKE(target_name = \"swat\")\ncount = 0\nwhile True:\n c.LISTEN( channel = \"test\", function = abc, args = (c,) )\n c.LISTEN( channel = \"DSP_MSG\", function = client_msg)\n\n if count == 0:\n if c.check(\"swat\") in c.HS_Devices:\n c.SEND_TO_CLIENT(target_name = \"swat\", data = \"Hello, what are you doing.\")\n count += 1\n```\n\nclientTwo.py\n\n```python\nfrom PySock import Sclient\n\nname = \"swat\"\n\ndef abc(data,con):\n print(f\"Message from : {data['sender_name']} => {data['data']}\")\n con.SEND(\"test\",\"What are you doing!\")\n\ndef client_msg(data,con):\n print(f\"Message From : {data['sender_name']} => {data['data']}\")\n con.SEND_TO_CLIENT(target_name = data[\"sender_name\"], data = f\"Hello From {name}\")\n\nc = Sclient(client_name = name, file = r'clientTwo_yml.yaml', debug = False)\nc.CLIENT(\"localhost\",1234)\nc.CREATE_CHANNEL(\"test\")\n\ncount = 0\nwhile True:\n c.LISTEN( channel = \"test\", function = abc, args = (c,) )\n c.LISTEN( channel = \"DSP_MSG\", function = client_msg, args = (c,))\n\n if count == 0:\n if \"swat\" in c.HS_Devices:\n c.SEND_TO_CLIENT(target_name = \"swat\", data = \"Hello, what are you doing.\")\n count += 1\n```\n\n### ===You can add as many client like these===\n\n\n### Result after running server.py, clientOne.py and clientTwo.py\n\n![Markdown logo](resource/PySock-test.png)\n\n---\n---\n\n## Now its time for normal multi-client server and clients:\n\n><h4 style = \"color : #7264a3\">Sample Server</h4>\n\nserver.py\n\n```python\nfrom PySock import server\n\ndef client_msg(data):\n print(f\"Message From : {data['sender_name']} => {data['data']}\")\n\ns = server(secure = False,debug = True)\ns.SERVER(\"localhost\",8888,10)\ns.CREATE_CHANNEL(\"test\")\n\nnew_client = []\n\nwhile True:\n for d in s.conClients:\n if d not in new_client:\n s.SEND(d,\"test\",\"Hello From Server\")\n new_client.append(d)\n\n s.LISTEN(\"test\",client_msg)\n```\n\n><h4 style = \"color : #7264a3\">Sample Clients</h4>\n\nclientOne.py\n\n```python\nfrom PySock import client\n\nname = \"shikhar\"\n\ndef abc(data,con):\n print(f\"Message from {data['sender_name']} : {data['data']}\")\n con.SEND(\"test\",\"Hello!\")\n\nc = client(client_name = name, debug = True)\nc.CLIENT(\"localhost\",8888)\nc.CREATE_CHANNEL(\"test\")\n\ncount = 0\nwhile True:\n c.LISTEN( channel = \"test\", function = abc, args = (c,) )\n\n if count == 0:\n c.SEND_TO_CLIENT(target_name = \"swat\", data = \"Hello, what are you doing.\")\n count += 1\n\n```\n\nclientTwo.py\n\n```python\nfrom PySock import client\n\ndef abc(data,con):\n print(f\"Message from {data['sender_name']} : {data['data']}\")\n con.SEND(\"test\",\"Hurrah! it's working.\")\n\ndef client_msg(data):\n print(f\"Message from : {data['sender_name']} => {data['data']}\")\n\nc = client(client_name = \"swat\", debug = True)\nc.CLIENT(\"localhost\",8888)\nc.CREATE_CHANNEL(\"test\")\nwhile True:\n c.LISTEN( channel = \"test\", function = abc, args = (c,) )\n\n c.LISTEN( channel = \"DSP_MSG\", function = client_msg)\n```\nThere is no docs for this library but i'm working on docs, hope it will uploaded soon.\n\n\nThanks for visiting \n\n---\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Pyckage for creating high level multi-client server with E2E encryption.",
"version": "0.3.2",
"project_urls": {
"Github": "https://github.com/ShikharY10/PySock",
"Homepage": "https://github.com/ShikharY10/PySock",
"Shikhar Yadav": "https://github.com/ShikharY10"
},
"split_keywords": [
"socket",
"tcp",
"stream",
"encrypted",
"e2e",
"multi-client-server"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "410a5da8baeadced4a52a3334485bda8653f452b922b21de14e21829823f49fc",
"md5": "6c8aa8fd784cf232d622cb0f032a5f27",
"sha256": "f3e8cc18bb24a52fb393b83cb7c8be3f451a041e052ad2e45f13a27a5f0cc791"
},
"downloads": -1,
"filename": "PySock-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6c8aa8fd784cf232d622cb0f032a5f27",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 18463,
"upload_time": "2021-08-16T09:43:30",
"upload_time_iso_8601": "2021-08-16T09:43:30.820554Z",
"url": "https://files.pythonhosted.org/packages/41/0a/5da8baeadced4a52a3334485bda8653f452b922b21de14e21829823f49fc/PySock-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ae41456cc659078957940841eb15783d5a1dc5f7b57fd6708f9798f54f3e3462",
"md5": "20568d74d2d052f878c209bcf329b585",
"sha256": "72e0691ddc1cc30511c997fdfeefad12068e18cc00063ac1d083f6f229da2920"
},
"downloads": -1,
"filename": "PySock-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "20568d74d2d052f878c209bcf329b585",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16254,
"upload_time": "2021-08-16T09:43:43",
"upload_time_iso_8601": "2021-08-16T09:43:43.568612Z",
"url": "https://files.pythonhosted.org/packages/ae/41/456cc659078957940841eb15783d5a1dc5f7b57fd6708f9798f54f3e3462/PySock-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-08-16 09:43:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ShikharY10",
"github_project": "PySock",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pysock"
}