release 0.0.1
parent
fb341274ee
commit
73ca696aef
|
@ -2,3 +2,11 @@ shard.lock
|
|||
bin
|
||||
drop
|
||||
lib
|
||||
|
||||
pongd
|
||||
pongc
|
||||
tcpd
|
||||
tcpc
|
||||
websocketd
|
||||
websocketc
|
||||
plumberd
|
||||
|
|
|
@ -0,0 +1,267 @@
|
|||
PACKAGE = 'plumberd'
|
||||
VERSION = '0.1.0'
|
||||
|
||||
PREFIX := /usr/local
|
||||
BINDIR := $(PREFIX)/bin
|
||||
LIBDIR := $(PREFIX)/lib
|
||||
SHAREDIR := $(PREFIX)/share
|
||||
INCLUDEDIR := $(PREFIX)/include
|
||||
MANDIR := $(SHAREDIR)/man
|
||||
|
||||
CC := cc
|
||||
AR := ar
|
||||
RANLIB := ranlib
|
||||
CFLAGS :=
|
||||
LDFLAGS :=
|
||||
|
||||
Q := @
|
||||
|
||||
all: tcpd tcpc pongd pongc plumberd websocketc websocketd
|
||||
@:
|
||||
|
||||
tcpd: src/tcpd.cr
|
||||
@echo '[01;35m CR > [01;37mtcpd[00m'
|
||||
$(Q)crystal src/tcpd.cr -o 'tcpd'
|
||||
|
||||
|
||||
tcpd.install: tcpd
|
||||
@echo '[01;31m IN > [01;37m$(BINDIR)/tcpd[00m'
|
||||
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||
$(Q)install -m0755 tcpd $(DESTDIR)$(BINDIR)/tcpd
|
||||
|
||||
tcpd.clean:
|
||||
@echo '[01;37m RM > [01;37mtcpd[00m'
|
||||
$(Q)rm -f tcpd
|
||||
|
||||
tcpd.uninstall:
|
||||
@echo '[01;37m RM > [01;37m$(BINDIR)/tcpd[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(BINDIR)/tcpd'
|
||||
|
||||
tcpc: src/tcpc.cr
|
||||
@echo '[01;35m CR > [01;37mtcpc[00m'
|
||||
$(Q)crystal src/tcpc.cr -o 'tcpc'
|
||||
|
||||
|
||||
tcpc.install: tcpc
|
||||
@echo '[01;31m IN > [01;37m$(BINDIR)/tcpc[00m'
|
||||
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||
$(Q)install -m0755 tcpc $(DESTDIR)$(BINDIR)/tcpc
|
||||
|
||||
tcpc.clean:
|
||||
@echo '[01;37m RM > [01;37mtcpc[00m'
|
||||
$(Q)rm -f tcpc
|
||||
|
||||
tcpc.uninstall:
|
||||
@echo '[01;37m RM > [01;37m$(BINDIR)/tcpc[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(BINDIR)/tcpc'
|
||||
|
||||
pongd: src/pongd.cr
|
||||
@echo '[01;35m CR > [01;37mpongd[00m'
|
||||
$(Q)crystal src/pongd.cr -o 'pongd'
|
||||
|
||||
|
||||
pongd.install: pongd
|
||||
@echo '[01;31m IN > [01;37m$(BINDIR)/pongd[00m'
|
||||
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||
$(Q)install -m0755 pongd $(DESTDIR)$(BINDIR)/pongd
|
||||
|
||||
pongd.clean:
|
||||
@echo '[01;37m RM > [01;37mpongd[00m'
|
||||
$(Q)rm -f pongd
|
||||
|
||||
pongd.uninstall:
|
||||
@echo '[01;37m RM > [01;37m$(BINDIR)/pongd[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(BINDIR)/pongd'
|
||||
|
||||
pongc: src/pongc.cr
|
||||
@echo '[01;35m CR > [01;37mpongc[00m'
|
||||
$(Q)crystal src/pongc.cr -o 'pongc'
|
||||
|
||||
|
||||
pongc.install: pongc
|
||||
@echo '[01;31m IN > [01;37m$(BINDIR)/pongc[00m'
|
||||
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||
$(Q)install -m0755 pongc $(DESTDIR)$(BINDIR)/pongc
|
||||
|
||||
pongc.clean:
|
||||
@echo '[01;37m RM > [01;37mpongc[00m'
|
||||
$(Q)rm -f pongc
|
||||
|
||||
pongc.uninstall:
|
||||
@echo '[01;37m RM > [01;37m$(BINDIR)/pongc[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(BINDIR)/pongc'
|
||||
|
||||
plumberd: src/plumberd.cr
|
||||
@echo '[01;35m CR > [01;37mplumberd[00m'
|
||||
$(Q)crystal src/plumberd.cr -o 'plumberd'
|
||||
|
||||
|
||||
plumberd.install: plumberd
|
||||
@echo '[01;31m IN > [01;37m$(BINDIR)/plumberd[00m'
|
||||
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||
$(Q)install -m0755 plumberd $(DESTDIR)$(BINDIR)/plumberd
|
||||
|
||||
plumberd.clean:
|
||||
@echo '[01;37m RM > [01;37mplumberd[00m'
|
||||
$(Q)rm -f plumberd
|
||||
|
||||
plumberd.uninstall:
|
||||
@echo '[01;37m RM > [01;37m$(BINDIR)/plumberd[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(BINDIR)/plumberd'
|
||||
|
||||
websocketc: src/websocketc.cr
|
||||
@echo '[01;35m CR > [01;37mwebsocketc[00m'
|
||||
$(Q)crystal src/websocketc.cr -o 'websocketc'
|
||||
|
||||
|
||||
websocketc.install: websocketc
|
||||
@echo '[01;31m IN > [01;37m$(BINDIR)/websocketc[00m'
|
||||
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||
$(Q)install -m0755 websocketc $(DESTDIR)$(BINDIR)/websocketc
|
||||
|
||||
websocketc.clean:
|
||||
@echo '[01;37m RM > [01;37mwebsocketc[00m'
|
||||
$(Q)rm -f websocketc
|
||||
|
||||
websocketc.uninstall:
|
||||
@echo '[01;37m RM > [01;37m$(BINDIR)/websocketc[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(BINDIR)/websocketc'
|
||||
|
||||
websocketd: src/websocketd.cr
|
||||
@echo '[01;35m CR > [01;37mwebsocketd[00m'
|
||||
$(Q)crystal src/websocketd.cr -o 'websocketd'
|
||||
|
||||
|
||||
websocketd.install: websocketd
|
||||
@echo '[01;31m IN > [01;37m$(BINDIR)/websocketd[00m'
|
||||
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||
$(Q)install -m0755 websocketd $(DESTDIR)$(BINDIR)/websocketd
|
||||
|
||||
websocketd.clean:
|
||||
@echo '[01;37m RM > [01;37mwebsocketd[00m'
|
||||
$(Q)rm -f websocketd
|
||||
|
||||
websocketd.uninstall:
|
||||
@echo '[01;37m RM > [01;37m$(BINDIR)/websocketd[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(BINDIR)/websocketd'
|
||||
|
||||
$(DESTDIR)$(PREFIX):
|
||||
@echo '[01;35m DIR > [01;37m$(PREFIX)[00m'
|
||||
$(Q)mkdir -p $(DESTDIR)$(PREFIX)
|
||||
$(DESTDIR)$(BINDIR):
|
||||
@echo '[01;35m DIR > [01;37m$(BINDIR)[00m'
|
||||
$(Q)mkdir -p $(DESTDIR)$(BINDIR)
|
||||
$(DESTDIR)$(LIBDIR):
|
||||
@echo '[01;35m DIR > [01;37m$(LIBDIR)[00m'
|
||||
$(Q)mkdir -p $(DESTDIR)$(LIBDIR)
|
||||
$(DESTDIR)$(SHAREDIR):
|
||||
@echo '[01;35m DIR > [01;37m$(SHAREDIR)[00m'
|
||||
$(Q)mkdir -p $(DESTDIR)$(SHAREDIR)
|
||||
$(DESTDIR)$(INCLUDEDIR):
|
||||
@echo '[01;35m DIR > [01;37m$(INCLUDEDIR)[00m'
|
||||
$(Q)mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
||||
$(DESTDIR)$(MANDIR):
|
||||
@echo '[01;35m DIR > [01;37m$(MANDIR)[00m'
|
||||
$(Q)mkdir -p $(DESTDIR)$(MANDIR)
|
||||
install: subdirs.install tcpd.install tcpc.install pongd.install pongc.install plumberd.install websocketc.install websocketd.install
|
||||
@:
|
||||
|
||||
subdirs.install:
|
||||
|
||||
uninstall: subdirs.uninstall tcpd.uninstall tcpc.uninstall pongd.uninstall pongc.uninstall plumberd.uninstall websocketc.uninstall websocketd.uninstall
|
||||
@:
|
||||
|
||||
subdirs.uninstall:
|
||||
|
||||
test: all subdirs subdirs.test
|
||||
@:
|
||||
|
||||
subdirs.test:
|
||||
|
||||
clean: tcpd.clean tcpc.clean pongd.clean pongc.clean plumberd.clean websocketc.clean websocketd.clean
|
||||
|
||||
distclean: clean
|
||||
|
||||
dist: dist-gz dist-xz dist-bz2
|
||||
$(Q)rm -- $(PACKAGE)-$(VERSION)
|
||||
|
||||
distdir:
|
||||
$(Q)rm -rf -- $(PACKAGE)-$(VERSION)
|
||||
$(Q)ln -s -- . $(PACKAGE)-$(VERSION)
|
||||
|
||||
dist-gz: $(PACKAGE)-$(VERSION).tar.gz
|
||||
$(PACKAGE)-$(VERSION).tar.gz: distdir
|
||||
@echo '[01;33m TAR > [01;37m$(PACKAGE)-$(VERSION).tar.gz[00m'
|
||||
$(Q)tar czf $(PACKAGE)-$(VERSION).tar.gz \
|
||||
$(PACKAGE)-$(VERSION)/src/websocketc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/websocketd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/tcpc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/pongc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/tcpd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/plumberd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/pongd.cr
|
||||
|
||||
dist-xz: $(PACKAGE)-$(VERSION).tar.xz
|
||||
$(PACKAGE)-$(VERSION).tar.xz: distdir
|
||||
@echo '[01;33m TAR > [01;37m$(PACKAGE)-$(VERSION).tar.xz[00m'
|
||||
$(Q)tar cJf $(PACKAGE)-$(VERSION).tar.xz \
|
||||
$(PACKAGE)-$(VERSION)/src/websocketc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/websocketd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/tcpc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/pongc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/tcpd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/plumberd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/pongd.cr
|
||||
|
||||
dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2
|
||||
$(PACKAGE)-$(VERSION).tar.bz2: distdir
|
||||
@echo '[01;33m TAR > [01;37m$(PACKAGE)-$(VERSION).tar.bz2[00m'
|
||||
$(Q)tar cjf $(PACKAGE)-$(VERSION).tar.bz2 \
|
||||
$(PACKAGE)-$(VERSION)/src/websocketc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/websocketd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/tcpc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/pongc.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/tcpd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/plumberd.cr \
|
||||
$(PACKAGE)-$(VERSION)/src/pongd.cr
|
||||
|
||||
help:
|
||||
@echo '[01;37m :: plumberd-0.1.0[00m'
|
||||
@echo ''
|
||||
@echo '[01;37mGeneric targets:[00m'
|
||||
@echo '[00m - [01;32mhelp [37m Prints this help message.[00m'
|
||||
@echo '[00m - [01;32mall [37m Builds all targets.[00m'
|
||||
@echo '[00m - [01;32mdist [37m Creates tarballs of the files of the project.[00m'
|
||||
@echo '[00m - [01;32minstall [37m Installs the project.[00m'
|
||||
@echo '[00m - [01;32mclean [37m Removes compiled files.[00m'
|
||||
@echo '[00m - [01;32muninstall [37m Deinstalls the project.[00m'
|
||||
@echo ''
|
||||
@echo '[01;37mCLI-modifiable variables:[00m'
|
||||
@echo ' - [01;34mCC [37m ${CC}[00m'
|
||||
@echo ' - [01;34mCFLAGS [37m ${CFLAGS}[00m'
|
||||
@echo ' - [01;34mLDFLAGS [37m ${LDFLAGS}[00m'
|
||||
@echo ' - [01;34mDESTDIR [37m ${DESTDIR}[00m'
|
||||
@echo ' - [01;34mPREFIX [37m ${PREFIX}[00m'
|
||||
@echo ' - [01;34mBINDIR [37m ${BINDIR}[00m'
|
||||
@echo ' - [01;34mLIBDIR [37m ${LIBDIR}[00m'
|
||||
@echo ' - [01;34mSHAREDIR [37m ${SHAREDIR}[00m'
|
||||
@echo ' - [01;34mINCLUDEDIR [37m ${INCLUDEDIR}[00m'
|
||||
@echo ' - [01;34mMANDIR [37m ${MANDIR}[00m'
|
||||
@echo ''
|
||||
@echo '[01;37mProject targets: [00m'
|
||||
@echo ' - [01;33mtcpd [37m crystal[00m'
|
||||
@echo ' - [01;33mtcpc [37m crystal[00m'
|
||||
@echo ' - [01;33mpongd [37m crystal[00m'
|
||||
@echo ' - [01;33mpongc [37m crystal[00m'
|
||||
@echo ' - [01;33mplumberd [37m crystal[00m'
|
||||
@echo ' - [01;33mwebsocketc [37m crystal[00m'
|
||||
@echo ' - [01;33mwebsocketd [37m crystal[00m'
|
||||
@echo ''
|
||||
@echo '[01;37mMakefile options:[00m'
|
||||
@echo ' - gnu: false'
|
||||
@echo ' - colors: true'
|
||||
@echo ''
|
||||
@echo '[01;37mRebuild the Makefile with:[00m'
|
||||
@echo ' zsh ./build.zsh -c'
|
||||
.PHONY: all subdirs clean distclean dist install uninstall help
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
package=plumberd
|
||||
version=0.1.0
|
||||
|
||||
targets=(tcpd tcpc pongd pongc plumberd websocketc websocketd)
|
||||
|
||||
for target in tcpd tcpc pongd pongc plumberd websocketc websocketd; do
|
||||
type[$target]=crystal
|
||||
sources[$target]=src/${target}.cr
|
||||
done
|
||||
|
34
src/main.cr
34
src/main.cr
|
@ -1,34 +0,0 @@
|
|||
require "./plumberd"
|
||||
|
||||
plumberd = NetworkD.new "plumber"
|
||||
|
||||
# --deny <in|out> <service> <url>
|
||||
# --allow <in|ou> <service> <url>
|
||||
# --redirect <service> <service>
|
||||
# --redirect <service-name> <new-service-name> <origin-url> <dest-url>
|
||||
|
||||
plumberd.parse_cli ARGV
|
||||
puts plumberd.to_s
|
||||
|
||||
plumberd.loop do |event|
|
||||
puts "there is an event!"
|
||||
case event
|
||||
when IPC::Event::Connection
|
||||
puts "\033[32mConnection:\033[00m fd #{event.connection.fd}"
|
||||
when IPC::Event::Disconnection
|
||||
puts "\033[32mDisconnection:\033[00m fd #{event.connection.fd}"
|
||||
when IPC::Event::ExtraSocket
|
||||
puts "\033[32mExtrasocket:\033[00m fd #{event.connection.fd}"
|
||||
when IPC::Event::Switch
|
||||
puts "\033[31mSwitch\033[00m"
|
||||
when IPC::Exception
|
||||
puts "\033[31mException\033[00m"
|
||||
when IPC::Event::Message
|
||||
puts "\033[32mthere is a message\033[00m"
|
||||
puts event.message.to_s
|
||||
|
||||
plumberd.service_lookup event.message, event.connection
|
||||
end
|
||||
end
|
||||
|
||||
# pp! rules.authorized? Rule::Direction::In, "authd", "tls:192.168.0.42"
|
|
@ -144,3 +144,38 @@ class NetworkD < IPC::NetworkD
|
|||
@rules.to_s + "\n" + @redirections.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
plumberd = NetworkD.new "plumber"
|
||||
|
||||
# --deny <in|out> <service> <url>
|
||||
# --allow <in|ou> <service> <url>
|
||||
# --redirect <service> <service>
|
||||
# --redirect <service-name> <new-service-name> <origin-url> <dest-url>
|
||||
|
||||
plumberd.parse_cli ARGV
|
||||
puts plumberd.to_s
|
||||
|
||||
plumberd.loop do |event|
|
||||
puts "there is an event!"
|
||||
case event
|
||||
when IPC::Event::Connection
|
||||
puts "\033[32mConnection:\033[00m fd #{event.connection.fd}"
|
||||
when IPC::Event::Disconnection
|
||||
puts "\033[32mDisconnection:\033[00m fd #{event.connection.fd}"
|
||||
when IPC::Event::ExtraSocket
|
||||
puts "\033[32mExtrasocket:\033[00m fd #{event.connection.fd}"
|
||||
when IPC::Event::Switch
|
||||
puts "\033[31mSwitch\033[00m"
|
||||
when IPC::Exception
|
||||
puts "\033[31mException\033[00m"
|
||||
when IPC::Event::Message
|
||||
puts "\033[32mthere is a message\033[00m"
|
||||
puts event.message.to_s
|
||||
|
||||
plumberd.service_lookup event.message, event.connection
|
||||
end
|
||||
end
|
||||
|
||||
# pp! rules.authorized? Rule::Direction::In, "authd", "tls:192.168.0.42"
|
||||
|
|
|
@ -5,7 +5,7 @@ require "./colors"
|
|||
verbosity = 1
|
||||
service_name = "pong"
|
||||
|
||||
OptionParser.parse! do |parser|
|
||||
OptionParser.parse do |parser|
|
||||
parser.on "-s service_name", "--service-name service_name", "URI" do |optsn|
|
||||
service_name = optsn
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ port_to_listen = 1234
|
|||
hostname = "localhost"
|
||||
requested_service_name = "pong"
|
||||
|
||||
OptionParser.parse! do |parser|
|
||||
OptionParser.parse do |parser|
|
||||
parser.on "-p port", "--port port", "Port to listen on." do |port|
|
||||
port_to_listen = port.to_u16
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ end
|
|||
service_name = "tcp"
|
||||
port_to_listen = 1234
|
||||
|
||||
OptionParser.parse! do |parser|
|
||||
OptionParser.parse do |parser|
|
||||
parser.on "-p port", "--port port", "Port to listen on." do |port|
|
||||
port_to_listen = port.to_u16
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ require "./ws"
|
|||
|
||||
uri = "ws://localhost:1234/pong"
|
||||
|
||||
OptionParser.parse! do |parser|
|
||||
OptionParser.parse do |parser|
|
||||
parser.on "-u uri", "--uri uri", "URI" do |opturi|
|
||||
uri = opturi
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@ service_name = "websocket"
|
|||
host = "0.0.0.0"
|
||||
port_to_listen = 1234
|
||||
|
||||
OptionParser.parse! do |parser|
|
||||
OptionParser.parse do |parser|
|
||||
parser.on "-l host", "--l host", "IP address to listen on." do |h|
|
||||
host = h
|
||||
end
|
||||
|
|
Reference in New Issue