Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
d0db0a7d94
|
|||
384c7368b2
|
|||
63e52b8c3e
|
|||
4622833ff5
|
|||
57fb2f7b99
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
BSD 2-Clause License
|
BSD 2-Clause License
|
||||||
|
|
||||||
Copyright (c) 2017, Bandie Canis
|
Copyright (c) 2017, Bandie <bandie@chaospott.de>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -12,8 +12,7 @@ The authentication is done via a SSL Client Certificate signed by an (self gener
|
|||||||
|
|
||||||
|
|
||||||
## Pic or didn't happen
|
## Pic or didn't happen
|
||||||

|

|
||||||
[Can't read a thing?](https://raw.githubusercontent.com/Bandie/ding/master/img/dingScreenshot.png)
|
|
||||||
|
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
@ -35,6 +34,8 @@ Step 1 to 3 can only be run on UNIX or GNU/Linux.
|
|||||||
6. Start the server using `./dingd` or `python .\dingd` on Windows. (You may want to put this in a tmux session. [Ctrl+B, D] ;) ).
|
6. Start the server using `./dingd` or `python .\dingd` on Windows. (You may want to put this in a tmux session. [Ctrl+B, D] ;) ).
|
||||||
7. Try out the client using `./ding <command>` òr `python .\ding <command>` on Windows.
|
7. Try out the client using `./ding <command>` òr `python .\ding <command>` on Windows.
|
||||||
|
|
||||||
|
### A word about the commands
|
||||||
|
It works much better to use (bash) scripts instead of executing the commands directly.
|
||||||
|
|
||||||
## Optional: Cleartext password with timeout
|
## Optional: Cleartext password with timeout
|
||||||
If you want to be sure that this power won't be abused by bad people using your computer, you may want to add a password (saved in cleartext).
|
If you want to be sure that this power won't be abused by bad people using your computer, you may want to add a password (saved in cleartext).
|
||||||
|
34
ding
34
ding
@ -3,7 +3,7 @@
|
|||||||
# Author: Bandie Canis
|
# Author: Bandie Canis
|
||||||
# License: 2-Clause BSD License
|
# License: 2-Clause BSD License
|
||||||
|
|
||||||
import sys, ssl, socket, os
|
import sys, ssl, socket, os, getopt
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
|
|
||||||
@ -14,14 +14,17 @@ certfile = None
|
|||||||
keyfile = None
|
keyfile = None
|
||||||
exitcode = 1
|
exitcode = 1
|
||||||
|
|
||||||
def readConfig():
|
def init(conf):
|
||||||
|
|
||||||
if(os.name == 'nt'):
|
if(conf == None):
|
||||||
CONFIG = "ding.win.cfg"
|
if(os.name == 'nt'):
|
||||||
|
CONFIG = "ding.win.cfg"
|
||||||
|
else:
|
||||||
|
CONFIG = "ding.cfg"
|
||||||
else:
|
else:
|
||||||
CONFIG = "ding.cfg"
|
CONFIG = conf
|
||||||
|
|
||||||
cfg = configparser.SafeConfigParser()
|
cfg = configparser.ConfigParser()
|
||||||
try:
|
try:
|
||||||
cfg.read(CONFIG)
|
cfg.read(CONFIG)
|
||||||
|
|
||||||
@ -67,7 +70,7 @@ def send(conn, cmd):
|
|||||||
quit(exitcode)
|
quit(exitcode)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(arg):
|
||||||
try:
|
try:
|
||||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||||
context.verify_mode = ssl.CERT_REQUIRED
|
context.verify_mode = ssl.CERT_REQUIRED
|
||||||
@ -85,7 +88,7 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
send(conn, bytes(sys.argv[1], sys.stdin.encoding))
|
send(conn, bytes(arg[0], sys.stdin.encoding))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print(sys.argv[0], ": Missing argument.\nSyntax: ", sys.argv[0], " <COMMAND>", file=sys.stderr)
|
print(sys.argv[0], ": Missing argument.\nSyntax: ", sys.argv[0], " <COMMAND>", file=sys.stderr)
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
@ -98,7 +101,16 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if(__name__ == "__main__"):
|
if(__name__ == "__main__"):
|
||||||
readConfig()
|
try:
|
||||||
main()
|
conf = None
|
||||||
quit(exitcode)
|
opts, args = getopt.getopt(sys.argv[1:], "c:")
|
||||||
|
for o, a in opts:
|
||||||
|
if o == "-c":
|
||||||
|
conf = a
|
||||||
|
init(conf)
|
||||||
|
main(args)
|
||||||
|
except getopt.GetoptError as e:
|
||||||
|
print("Error using options. Allowed options:\n-c [FILE] - Config file\n")
|
||||||
|
quit(2)
|
||||||
|
|
||||||
|
quit(exitcode)
|
||||||
|
28
dingd
28
dingd
@ -3,7 +3,7 @@
|
|||||||
# Author: Bandie Canis
|
# Author: Bandie Canis
|
||||||
# License: 2-Clause BSD license
|
# License: 2-Clause BSD license
|
||||||
|
|
||||||
import ssl, socket, subprocess, time, os, sys
|
import ssl, socket, subprocess, time, os, sys, getopt
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
CONFIG = None
|
CONFIG = None
|
||||||
@ -26,7 +26,7 @@ def getTimestamp():
|
|||||||
return t
|
return t
|
||||||
|
|
||||||
def execFromConfig(option, pw=False):
|
def execFromConfig(option, pw=False):
|
||||||
cfg = configparser.SafeConfigParser()
|
cfg = configparser.ConfigParser()
|
||||||
cfg.read(CONFIG)
|
cfg.read(CONFIG)
|
||||||
|
|
||||||
if(pw):
|
if(pw):
|
||||||
@ -107,16 +107,19 @@ def main():
|
|||||||
except EOFError:
|
except EOFError:
|
||||||
print(getTimestamp(), "EOF")
|
print(getTimestamp(), "EOF")
|
||||||
|
|
||||||
def init():
|
def init(cfg=None):
|
||||||
|
|
||||||
global CONFIG, host, port, cafile, certfile, keyfile, pw_on, password, pwtimeout, tmppw_on, context, bindsocket
|
global CONFIG, host, port, cafile, certfile, keyfile, pw_on, password, pwtimeout, tmppw_on, context, bindsocket
|
||||||
|
|
||||||
if(os.name == 'nt'):
|
if(cfg==None):
|
||||||
CONFIG = "dingd.win.cfg"
|
if(os.name == 'nt'):
|
||||||
|
CONFIG = "dingd.win.cfg"
|
||||||
|
else:
|
||||||
|
CONFIG = "dingd.cfg"
|
||||||
else:
|
else:
|
||||||
CONFIG = "dingd.cfg"
|
CONFIG = cfg
|
||||||
|
|
||||||
cfg = configparser.SafeConfigParser()
|
cfg = configparser.ConfigParser()
|
||||||
cfg.read(CONFIG)
|
cfg.read(CONFIG)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -176,10 +179,17 @@ def init():
|
|||||||
|
|
||||||
|
|
||||||
if(__name__ == "__main__"):
|
if(__name__ == "__main__"):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
init()
|
conf = None
|
||||||
|
opts, args = getopt.getopt(sys.argv[1:], "c:")
|
||||||
|
for o, a in opts:
|
||||||
|
if o == "-c":
|
||||||
|
conf = a
|
||||||
|
init(conf)
|
||||||
main()
|
main()
|
||||||
|
except getopt.GetoptError as e:
|
||||||
|
print("Error using options. Allowed options:\n-c [FILE] - Config file\n")
|
||||||
|
quit(2)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\r\rServer stopped.")
|
print("\r\rServer stopped.")
|
||||||
|
|
||||||
|
10
systemd/dingd.service
Normal file
10
systemd/dingd.service
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=dingd Service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/root/ding/dingd -c /path/to/config/file/dingd.cfg
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
Reference in New Issue
Block a user