From f939158f425d385089a633d6af68d2d1b7d1de88 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 16 Mar 2021 20:59:44 +1100 Subject: [PATCH] Moved Doorparty out into its own container --- Dockerfile | 31 +---------------------------- doorparty.js | 38 ++++++++++++++++++++++++++++++++++++ supervisord.d/doorparty.conf | 3 --- 3 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 doorparty.js delete mode 100644 supervisord.d/doorparty.conf diff --git a/Dockerfile b/Dockerfile index 528d647..4b63ba0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,36 +44,6 @@ RUN apt-get update \ && rm -rf /opt/sbbs/repo \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Add Doorparty -RUN apt-get update \ - && apt-get install -yqq golang git \ - && cd /tmp && git clone https://github.com/echicken/dpc2 \ - && cd dpc2 && echo -n 'ZGlmZiAtLWdpdCBhL2Rvb3JwYXJ0eS1jb25uZWN0b3IuZ28gYi9kb29ycGFydHktY29ubmVjdG9y\ -LmdvCmluZGV4IDE4NzNhZTUuLjc3NmFhOGUgMTAwNjQ0Ci0tLSBhL2Rvb3JwYXJ0eS1jb25uZWN0\ -b3IuZ28KKysrIGIvZG9vcnBhcnR5LWNvbm5lY3Rvci5nbwpAQCAtMTMyLDcgKzEzMiw3IEBAIGZ1\ -bmMgaW5pdCgpIHsKIAogZnVuYyBtYWluKCkgewogCi0JY2ZnLCBlcnIgOj0gaW5pLkxvYWQoImRv\ -b3JwYXJ0eS1jb25uZWN0b3IuaW5pIikKKwljZmcsIGVyciA6PSBpbmkuTG9hZCgiL29wdC9zYmJz\ -L2N0cmwvZG9vcnBhcnR5LWNvbm5lY3Rvci5pbmkiKQogCWlmIGVyciAhPSBuaWwgewogCQlsb2cu\ -RmF0YWxmKCJFcnJvciByZWFkaW5nIGRvb3JwYXJ0eS1jb25uZWN0b3IuaW5pOiAldiIsIGVycikK\ -IAl9Cg=='|base64 -d |git apply \ - && go get gopkg.in/ini.v1 \ - && go get golang.org/x/crypto/ssh \ - && go build -i doorparty-connector.go \ - && echo -n 'LS0tIC9zcnYvZG9ja2VyL3NiYnMvbW9kcy9kb29ycGFydHkuanMJMjAyMS0wMS0xMyAyMjozNTox\ -Ni4wNzQyNzk2MDggKzExMDAKKysrIC4vc3luY2hyb25ldC9kb29ycGFydHkuanMJMjAyMS0wMS0x\ -MyAyMzoyMjoyMi44MzgwNjU4MzIgKzExMDAKQEAgLTMzLDcgKzMzLDcgQEAKICAgICAoY2ZnLnR1\ -bm5lbF9ob3N0IHx8ICdsb2NhbGhvc3QnKSArICc6JyArIChjZmcudHVubmVsX3BvcnQgfHwgOTk5\ -OSksCiAgICAgZ2V0X3Bhc3N3b3JkKCksIC8vIHBhc3N3b3JkCiAgICAgdXNlci5hbGlhcywKLSAg\ -ICBhcmd2Lmxlbmd0aCA/IGFyZ3ZbMF0gOiB1bmRlZmluZWQKKyAgICBhcmd2Lmxlbmd0aCA/ICd4\ -dHJuPScrYXJndlswXSA6IHVuZGVmaW5lZAogKTsKIAogY29uc29sZS5hdHRyaWJ1dGVzID0gYXR0\ -cjsK'|base64 -d |git apply \ - && mv doorparty-connector synchronet/doorparty.js /opt/sbbs/exec \ - && mv doorparty-connector.ini /opt/sbbs/ctrl.orig \ - && apt-get -y purge golang git \ - && apt-get -y autoremove \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - # Add PHP RUN apt-get update \ && apt-get install -yqq composer php-cgi php-fpm php-gd php-sqlite3 php-xml \ @@ -87,6 +57,7 @@ ENV SBBSEXEC=/opt/sbbs/exec ENV PATH=$PATH:${SBBSEXEC} COPY start.sh ${SBBSEXEC}/ +COPY doorparty.js ${SBBSEXEC}/ COPY main.cnf /opt/sbbs/ctrl.orig/ VOLUME [ "/var/lib/zerotier-one" ] diff --git a/doorparty.js b/doorparty.js new file mode 100644 index 0000000..32ce7df --- /dev/null +++ b/doorparty.js @@ -0,0 +1,38 @@ +load('sbbsdefs.js'); +var userprops = load({}, "userprops.js"); +var cfg = load({}, 'modopts.js', "doorparty") || {}; + +var attr = console.attributes; + +function make_password() { + var c; + var p = []; + while (p.length < 8) { + c = ascii(Math.ceil(Math.random() * 58) + 32); + if (p.indexOf(c) > -1) continue; + p.push(c); + } + return p.join(''); +} + +function get_password() { + if (cfg.password) return cfg.password; // If a system-wide password has been set, use it + var password = userprops.get('doorparty', 'password', ''); + if (password != '') return password; // If the user has a DoorParty password on file, use it + password = make_password(); + userprops.set('doorparty', 'password', password); // Store a DoorParty password for this user + return password; +} + +console.clear(LIGHTGRAY); +console.putmsg('Connecting to DoorParty, please wait ...'); + +bbs.rlogin_gate( + (cfg.tunnel_host || 'localhost') + ':' + (cfg.tunnel_port || 9999), + get_password(), // password + user.alias, + argv.length ? 'xtrn='+argv[0] : undefined +); + +console.attributes = attr; +console.clear(); diff --git a/supervisord.d/doorparty.conf b/supervisord.d/doorparty.conf deleted file mode 100644 index cdb6fa0..0000000 --- a/supervisord.d/doorparty.conf +++ /dev/null @@ -1,3 +0,0 @@ -[program:doorparty] -command=/opt/sbbs/exec/doorparty-connector -stopwaitsecs=60