Skip to content
Open
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dockerfile for talek
FROM golang:1.12
FROM golang:1.20
MAINTAINER Raymond Cheng <me@raymondcheng.net>
USER root

Expand Down
63 changes: 59 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
docker_compose?= $(shell if which podman|grep -q .; then echo DOCKER_HOST="unix://$$XDG_RUNTIME_DIR/podman/podman.sock" docker-compose; else echo docker-compose; fi)
docker_user?=$(shell if echo ${docker}|grep -q podman; then echo 0:0; else echo ${uid}:${gid}; fi)
docker=$(shell if which podman|grep -q .; then echo podman; else echo docker; fi)
net_name=talek_net

.PHONY: get-tools test lint unit

get-tools:
Expand Down Expand Up @@ -25,9 +30,59 @@ ci: lint
goveralls -coverprofile=overalls.coverprofile -service=travis-ci; \
fi

docker-build:
docker build -t talek-base:latest ./
docker build -t talek-replica:latest ./cli/talekreplica/
docker-build.stamp:
$(docker) build -t talek-base:latest ./
#$(docker) build -t talek-replica:latest ./cli/talekreplica/
touch $@

docker-bash:
docker run -it talek-base:latest bash
$(docker) run -it talek-base:latest bash

$(net_name)/talek.conf: docker-build-cli.stamp
$(docker) run --rm -v ./$(net_name):/talek_shared talek-cli bash -c "cd /talek_shared && talekutil --common --outfile common.conf && \
talekutil --replica --incommon common.conf --private --index 0 --name replica0 --address http://127.0.0.1:8081 --outfile replica0.json && \
talekutil --replica --incommon common.conf --private --index 1 --name replica1 --address http://127.0.0.1:8082 --outfile replica1.json && \
talekutil --replica --incommon common.conf --private --index 2 --name replica2 --address http://127.0.0.1:8083 --outfile replica2.json && \
talekutil --trustdomain --index 0 --name replica0 --address http://127.0.0.1:8081 --infile replica0.json --outfile replica0.pub.json && \
talekutil --trustdomain --index 1 --name replica1 --address http://127.0.0.1:8082 --infile replica1.json --outfile replica1.pub.json && \
talekutil --trustdomain --index 2 --name replica2 --address http://127.0.0.1:8083 --infile replica2.json --outfile replica2.pub.json && \
talekutil --client --infile common.conf --trustdomains replica0.pub.json,replica1.pub.json,replica2.pub.json --outfile talek.conf && \
sed -i -e 's/\"FrontendAddr\": \"\"/\"FrontendAddr\": \"http:\/\/127.0.0.1:8080\/rpc\"/' talek.conf"

docker-build-cli.stamp: docker-build.stamp
$(docker) build -t talek-cli:latest ./cli/
touch $@

testnet-start: $(net_name)/running.stamp

$(net_name)/running.stamp: $(net_name)/talek.conf
cd $(net_name); DOCKER_USER=${docker_user} $(docker_compose) up --remove-orphans -d; $(docker_compose) top
touch $(net_name)/running.stamp

testnet-stop:
-cd $(net_name) && DOCKER_USER=${docker_user} $(docker_compose) down --remove-orphans; rm -fv running.stamp

testnet-clean: testnet-stop
-$(docker) rmi talek-cli
-$(docker) rmi talek-base
rm -f docker-build-cli.stamp
rm -f docker-build.stamp

testnet-cli:
$(docker) run --rm --network host -it -v ./$(net_name):/talek_shared -w /talek_shared talek-cli:latest bash

testnet-test-write-and-read: $(net_name)/running.stamp
$(docker) run --rm --network host -it -v ./$(net_name):/talek_shared -w /talek_shared talek-cli:latest bash -c " \
rm -f test_output.log && \
talekclient --verbose --create --topic writehandle && \
talekclient --verbose --topic writehandle --share readhandle && \
talekclient --verbose --topic writehandle --write Hello1 && \
talekclient --verbose --topic writehandle --write Hello2 && \
talekclient --verbose --topic writehandle --write Hello3 && \
talekclient --verbose --topic readhandle --read | tee >(grep Hello >> test_output.log) && \
talekclient --verbose --topic readhandle --read | tee >(grep Hello >> test_output.log) && \
talekclient --verbose --topic readhandle --read | tee >(grep Hello >> test_output.log) && \
cat test_output.log && \
sha256sum -c <<<'81ff3368be913d26d96879a0215e4fbace25449f029c7aabf07350207f0aa980 test_output.log' \
&& echo 'Successfully wrote and read three items!' \
|| echo 'Failed to read something.'"
13 changes: 13 additions & 0 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Dockerfile for talek
FROM talek-base:latest
MAINTAINER Masala <masala@riseup.net>
USER root

# build and install talek cli tools
RUN go mod download
RUN cd cli/talekutil && go install
RUN cd cli/clinfo && go install
RUN cd cli/talekclient && go install
RUN cd cli/talekfrontend && go install
RUN cd cli/talekreplica && go install
RUN cd cli/talekutil && go install
14 changes: 12 additions & 2 deletions cli/talekclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,18 @@ func main() {
}
topic = *nt
} else {
if err = topic.UnmarshalText(topicdata); err != nil {
panic(err)
err = topic.UnmarshalText(topicdata)
if err != nil {
// if it is a read-only share, unmarshal only the Handle part
if *read {
topic.SigningPrivateKey = new([64]byte)
err = topic.Handle.UnmarshalText(topicdata)
if err != nil {
panic(err)
}
} else {
panic(err)
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ go 1.12

require (
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412
github.com/barnex/cuda5 v0.0.0-20170131213030-57cec7ab46da
github.com/coreos/etcd v0.0.0-20170414193847-e2d0db95ebbc
github.com/coreos/go-systemd v0.0.0-20170324095819-1f9909e51b2d // indirect
github.com/coreos/pkg v0.0.0-20170405072653-099530d80109 // indirect
github.com/dchest/siphash v1.2.1
github.com/foobaz/go-zopfli v0.0.0-20140122214029-7432051485e2
github.com/go-gl/cl v0.0.0-20160402050751-283e73a0ca2a
github.com/google/zopfli v0.0.0-20190118173051-ef109ddf1649
github.com/gorilla/rpc v1.1.0
github.com/spf13/pflag v0.0.0-20170412152249-e453343e6260
github.com/willscott/bloom v0.0.0-20190611115233-60e4b211444f
Expand Down
8 changes: 3 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
github.com/barnex/cuda5 v0.0.0-20170131213030-57cec7ab46da/go.mod h1:GnBnFz4V/+kxwKFnquvOOi+IjZoVJsIUbcAVOXLCxCo=
github.com/coreos/etcd v0.0.0-20170414193847-e2d0db95ebbc h1:VR+2Zdu4LwGrVDMUdVphibZfMHoFEnb5t8xQDWi1IAk=
github.com/coreos/etcd v0.0.0-20170414193847-e2d0db95ebbc/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-systemd v0.0.0-20170324095819-1f9909e51b2d h1:JmJsvY9kF4oqiNrI+3FEoTtpRu8HvlxPgCSIrxxoZTQ=
github.com/coreos/go-systemd v0.0.0-20170324095819-1f9909e51b2d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20170405072653-099530d80109 h1:8RxHvQFXd1AgM3q7iG92w06tQKiuqpHCNf5lVKs9bbs=
github.com/coreos/pkg v0.0.0-20170405072653-099530d80109/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/siphash v1.1.0 h1:1Rs9eTUlZLPBEvV+2sTaM8O0NWn0ppbgqS7p11aWawI=
github.com/dchest/siphash v1.1.0/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4=
github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4=
github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4=
github.com/foobaz/go-zopfli v0.0.0-20140122214029-7432051485e2 h1:VA6jElpcJ+wkwEBufbnVkSBCA2TEnxdRppjRT5Kvh0A=
github.com/foobaz/go-zopfli v0.0.0-20140122214029-7432051485e2/go.mod h1:Yi95+RbwKz7uGndSuUhoq7LJKh8qH8DT9fnL4ewU30k=
github.com/go-gl/cl v0.0.0-20160402050751-283e73a0ca2a h1:XIGMyilyw1fCjQW2XBAQYNSqBjz6ZEDSQcU24zjC/TI=
github.com/go-gl/cl v0.0.0-20160402050751-283e73a0ca2a/go.mod h1:x9JFrvJwNd4nJdwEzeF+68Bul1G/WftfhxdnJF85OUc=
github.com/google/zopfli v0.0.0-20190118173051-ef109ddf1649 h1:zDqfvNfJRhocVF/Ul+M/hhhewIw9R8xJwDOGrHDKzzI=
github.com/google/zopfli v0.0.0-20190118173051-ef109ddf1649/go.mod h1:s2ULOAKrLKt7BL/w7MwT3F8bAXHc792qVNGEd5Wp7OQ=
github.com/gorilla/rpc v1.1.0 h1:marKfvVP0Gpd/jHlVBKCQ8RAoUPdX7K1Nuh6l1BNh7A=
github.com/gorilla/rpc v1.1.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/pflag v0.0.0-20170412152249-e453343e6260 h1:Rel8ggqtJ8xEfIJKPRDcF/f8a5Ukr6Wsyen4uGcYh+k=
github.com/spf13/pflag v0.0.0-20170412152249-e453343e6260/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/willscott/bloom v0.0.0-20190611115233-60e4b211444f h1:HDruOClXOci/Duq+8QQZZTt2S2BvgT70pyX3nsVZbPQ=
github.com/willscott/bloom v0.0.0-20190611115233-60e4b211444f/go.mod h1:ioaxSY0uYBnMt/u6zoCy87QnCVbch+cfpqo9rtSfK2s=
Expand Down
43 changes: 43 additions & 0 deletions talek_net/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "2"

services:

frontend:
restart: "no"
image: talek-cli
volumes:
- ./:/talek_shared
working_dir: /talek_shared
command: talekfrontend -l ":8080" --verbose
network_mode: host
depends_on:
- replica0
- replica1
- replica2

replica0:
restart: "no"
image: talek-cli
volumes:
- ./:/talek_shared
working_dir: /talek_shared
command: talekreplica -l ":8081" -c /talek_shared/replica0.json
network_mode: host

replica1:
restart: "no"
image: talek-cli
volumes:
- ./:/talek_shared
working_dir: /talek_shared
command: talekreplica -l ":8082" -c /talek_shared/replica1.json
network_mode: host

replica2:
restart: "no"
image: talek-cli
volumes:
- ./:/talek_shared
working_dir: /talek_shared
command: talekreplica -l ":8083" -c /talek_shared/replica2.json
network_mode: host