Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customized IP address hosting, executable file for 2 platforms, pycharm ide support, windows escape sequence correction #60

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/aws.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/sanctuary.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 29 additions & 9 deletions chatroom.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/usr/bin/env python

import asyncio, json, websockets, sys, click, time
import asyncio
import json
import sys
import time

import click
import colorama
import websockets

colorama.init()

USERS = set()

Expand Down Expand Up @@ -32,15 +40,18 @@ async def chatroom(websocket, path):
try:
async for message in websocket:
data = json.loads(message)
print(" > [" + str(time.ctime()) + "] [" + str(data["roomiden"]) + "] User '" + str(data["username"]) + "' sends message '" + str(data["textmesg"]) + "'")
print(" > [" + str(time.ctime()) + "] [" + str(data["roomiden"]) + "] User '" + str(
data["username"]) + "' sends message '" + str(data["textmesg"]) + "'")
await notify_mesej(data["username"], data["roomiden"], data["textmesg"])
finally:
await unregister(websocket)


def servenow(netpdata="127.0.0.1", chatport="9696"):
try:
print(" > [" + str(time.ctime()) + "] [HOLAUSER] Sanctuary was started up on 'ws://" + str(netpdata) + ":" + str(chatport) + "/'")
print(
" > [" + str(time.ctime()) + "] [HOLAUSER] Sanctuary was started up on 'ws://" + str(netpdata) + ":" + str(
chatport) + "/'")
start_server = websockets.serve(chatroom, netpdata, int(chatport))
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
Expand All @@ -50,21 +61,30 @@ def servenow(netpdata="127.0.0.1", chatport="9696"):


@click.command()
@click.option("-i", "--server-ip", "servip", help="Extra IP Address configuration", default=None, required=False)
@click.option("-c", "--chatport", "chatport", help="Set the port value for WebSockets [0-65536]", required=True)
@click.option("-6", "--ipprotv6", "netprotc", flag_value="ipprotv6", help="Start the server on an IPv6 address", required=True)
@click.option("-4", "--ipprotv4", "netprotc", flag_value="ipprotv4", help="Start the server on an IPv4 address", required=True)
@click.option("-6", "--ipprotv6", "netprotc", flag_value="ipprotv6", help="Start the server on an IPv6 address",
required=True)
@click.option("-4", "--ipprotv4", "netprotc", flag_value="ipprotv4", help="Start the server on an IPv4 address",
required=True)
@click.version_option(version="22072020", prog_name="Sanctuary WebSockets by AstroSonic")
def mainfunc(chatport, netprotc):
def mainfunc(chatport, netprotc, servip):
print(" > [" + str(time.ctime()) + "] [HOLAUSER] Starting Sanctuary...")
netpdata = ""
if netprotc == "ipprotv6":
print(" > [" + str(time.ctime()) + "] [HOLAUSER] IP version : 6")
netpdata = "::"
if servip is None:
netpdata = "::"
else:
netpdata = servip
elif netprotc == "ipprotv4":
print(" > [" + str(time.ctime()) + "] [HOLAUSER] IP version : 4")
netpdata = "0.0.0.0"
if servip is None:
netpdata = "0.0.0.0"
else:
netpdata = servip
servenow(netpdata, chatport)


if __name__ == "__main__":
mainfunc()
mainfunc()
Binary file added dist/chatroom Linux.zip
Binary file not shown.
Binary file added dist/chatroom Windows.zip
Binary file not shown.
Binary file added dist/servchat Linux.zip
Binary file not shown.
Binary file added dist/servchat Windows.zip
Binary file not shown.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ MarkupSafe==1.1.1
six==1.15.0
websockets==8.1
Werkzeug==1.0.1
colorama==0.4.3
23 changes: 17 additions & 6 deletions servchat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from flask import Flask, render_template
import click
import colorama
from flask import Flask, render_template

colorama.init()

servchat = Flask(__name__)

Expand All @@ -17,10 +19,13 @@ def chrumnow(netpdata, servport):
@click.command()
@click.option("-s", "--servport", "servport", help="Set the port value for Chatroom [0-65536]", required=True)
@click.option("-c", "--chatport", "chatport", help="Set the port value for WebSockets [0-65536]", required=True)
@click.option("-6", "--ipprotv6", "netprotc", flag_value="ipprotv6", help="Start the server on an IPv6 address", required=True)
@click.option("-4", "--ipprotv4", "netprotc", flag_value="ipprotv4", help="Start the server on an IPv4 address", required=True)
@click.option("-6", "--ipprotv6", "netprotc", flag_value="ipprotv6", help="Start the server on an IPv6 address",
required=True)
@click.option("-4", "--ipprotv4", "netprotc", flag_value="ipprotv4", help="Start the server on an IPv4 address",
required=True)
@click.option("-i", "--server-ip", "servip", help="Extra IP Address configuration", default=None, required=False)
@click.version_option(version="22072020", prog_name="Sanctuary Chatroom by AstroSonic")
def mainfunc(servport, chatport, netprotc):
def mainfunc(servport, chatport, netprotc, servip):
global chatp0rt
chatp0rt = chatport
print(" * Starting Sanctuary...")
Expand All @@ -32,10 +37,16 @@ def mainfunc(servport, chatport, netprotc):
netpdata = ""
if netprotc == "ipprotv6":
print(" * IP version : 6")
netpdata = "::"
if servip is None:
netpdata = "::"
else:
netpdata = servip
elif netprotc == "ipprotv4":
print(" * IP version : 4")
netpdata = "0.0.0.0"
if servip is None:
netpdata = "0.0.0.0"
else:
netpdata = servip
chrumnow(netpdata, servport)


Expand Down