Compare commits
4 Commits
e6643cba6b
...
1.0.0-1-g9
Author | SHA1 | Date | |
---|---|---|---|
9c26b79769 | |||
932aa46a18 | |||
b826f7de2d | |||
3c44e82b65 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@
|
||||
/vendor
|
||||
/bin
|
||||
/testdata
|
||||
/release
|
||||
/release
|
||||
/out
|
50
Jenkinsfile
vendored
Normal file
50
Jenkinsfile
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
@Library('cadoles@gitea-release') _
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'Dockerfile'
|
||||
dir 'misc/ci'
|
||||
}
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Lint') {
|
||||
steps {
|
||||
script {
|
||||
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||
sh 'make lint'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
script {
|
||||
sh 'make test'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Release') {
|
||||
steps {
|
||||
script {
|
||||
sh 'make tidy'
|
||||
sh 'ARCH_TARGETS="amd64 arm arm64" make release'
|
||||
|
||||
def attachments = sh(returnStdout: true, script: 'find release -maxdepth 1 -type f').split(' ')
|
||||
gitea.release('forge-jenkins', 'Cadoles', 'go-http-peering', [
|
||||
'attachments': attachments
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
Makefile
21
Makefile
@ -3,33 +3,18 @@ test:
|
||||
go test -cover -v ./...
|
||||
|
||||
watch:
|
||||
modd
|
||||
go run -mod=readonly github.com/cortesi/modd/cmd/modd@latest
|
||||
|
||||
release:
|
||||
script/release
|
||||
|
||||
deps:
|
||||
GO111MODULE=off go get -u golang.org/x/tools/cmd/godoc
|
||||
GO111MODULE=off go get -u github.com/cortesi/modd/cmd/modd
|
||||
GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
GO111MODULE=off go get -u github.com/lmika/goseq
|
||||
|
||||
tidy:
|
||||
go mod tidy
|
||||
|
||||
lint:
|
||||
golangci-lint run --tests=false --enable-all
|
||||
|
||||
sequence-diagram: sd-advertise sd-update sd-ping
|
||||
|
||||
sd-%:
|
||||
goseq doc/sequence-diagram/$*.seq > doc/sequence-diagram/$*.svg
|
||||
|
||||
doc:
|
||||
@echo "open your browser to http://localhost:6060/pkg/forge.cadoles.com/Cadoles/go-http-peering to see the documentation"
|
||||
godoc -http=:6060
|
||||
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0 run --tests=false --enable-all
|
||||
|
||||
bin/keygen:
|
||||
go build -o bin/keygen ./cmd/keygen
|
||||
CGO_ENABLED=0 go build -o bin/keygen ./cmd/keygen
|
||||
|
||||
.PHONY: test lint doc sequence-diagram bin/keygen release
|
@ -8,17 +8,15 @@ Librairie implémentant un protocole d'authentification par "appairage" d'un ser
|
||||
|
||||
### Annonce du client
|
||||
|
||||

|
||||

|
||||
|
||||
### Mise à jour des attributs
|
||||
|
||||

|
||||

|
||||
|
||||
### Ping
|
||||
|
||||

|
||||
|
||||
**Statut** Instable
|
||||

|
||||
|
||||
## Licence
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
Client -> Server: POST /advertise\nX-Server-Token: <JWT_TOKEN>\n\n{"Attributes": <PEER_ATTRIBUTES>, "PublicKey": <PUBLIC_KEY> }
|
||||
Server -> Client: 201 Created
|
@ -1,36 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- Generated by SVGo -->
|
||||
<svg width="589" height="212"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'DejaVuSans';
|
||||
src: url('https://fontlibrary.org/assets/fonts/dejavu-sans/f5ec8426554a3a67ebcdd39f9c3fee83/49c0f03ec2fa354df7002bcb6331e106/DejaVuSansBook.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<line x1="45" y1="24" x2="45" y2="188" style="stroke-dasharray:8,8;stroke-width:2px;stroke:black;" />
|
||||
<rect x="8" y="8" width="75" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="24" y="29" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Client</text>
|
||||
<rect x="8" y="172" width="75" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="24" y="193" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Client</text>
|
||||
<line x1="539" y1="24" x2="539" y2="188" style="stroke-dasharray:8,8;stroke-width:2px;stroke:black;" />
|
||||
<rect x="497" y="8" width="84" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="513" y="29" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Server</text>
|
||||
<rect x="497" y="172" width="84" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="513" y="193" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Server</text>
|
||||
<rect x="61" y="56" width="462" height="62" style="fill:white;stroke:white;" />
|
||||
<text x="237" y="68" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >POST /advertise</text>
|
||||
<text x="184" y="84" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >X-Server-Token: <JWT_TOKEN></text>
|
||||
<text x="61" y="116" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >{"Attributes": <PEER_ATTRIBUTES>, "PublicKey": <PUBLIC_KEY> }</text>
|
||||
<line x1="45" y1="122" x2="539" y2="122" style="stroke:black;stroke-width:2px;" />
|
||||
<polyline points="530,117 539,122 530,127" style="fill:black;stroke-width:2px;stroke:black;" />
|
||||
<rect x="249" y="138" width="87" height="14" style="fill:white;stroke:white;" />
|
||||
<text x="249" y="150" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >201 Created</text>
|
||||
<line x1="539" y1="156" x2="45" y2="156" style="stroke:black;stroke-width:2px;" />
|
||||
<polyline points="54,151 45,156 54,161" style="fill:black;stroke-width:2px;stroke:black;" />
|
||||
</svg>
|
Before Width: | Height: | Size: 2.4 KiB |
15
doc/sequence-diagram/advertising.plantuml
Normal file
15
doc/sequence-diagram/advertising.plantuml
Normal file
@ -0,0 +1,15 @@
|
||||
@startuml
|
||||
Client -> Server: POST /advertise\nX-Server-Token: <JWT_TOKEN>\n\n{"Attributes": <PEER_ATTRIBUTES>, "PublicKey": <PUBLIC_KEY> }
|
||||
Server -> Server: Validate server token
|
||||
alt Success
|
||||
Server -> Server: Create peer with public key and attributes
|
||||
Server -> Server: Update last contact for peer ID
|
||||
Server -> Client: 201 Created
|
||||
else Invalid server token
|
||||
Server -> Client: 401 Unauthorized
|
||||
else Malformed advertising request
|
||||
Server -> Client: 400 Bad request
|
||||
else Unexpected error
|
||||
Server -> Client: 500 Server error
|
||||
end
|
||||
@enduml
|
BIN
doc/sequence-diagram/advertising.png
Normal file
BIN
doc/sequence-diagram/advertising.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
17
doc/sequence-diagram/ping.plantuml
Normal file
17
doc/sequence-diagram/ping.plantuml
Normal file
@ -0,0 +1,17 @@
|
||||
@startuml
|
||||
Client -> Server: POST /ping\nX-Server-Token: <JWT_TOKEN>\nX-Client-Token: <JWT_TOKEN>
|
||||
Server -> Server: Validate client/server tokens
|
||||
alt Success
|
||||
Server -> Server: Update last contact for peer ID
|
||||
Server -> Client: 204 No Content
|
||||
else Invalid client or server token
|
||||
Server -> Client: 400 Bad request
|
||||
else Peer not found
|
||||
Server -> Client: 401 Unauthorized
|
||||
else Peer rejected
|
||||
Server -> Client: 403 Forbidden
|
||||
else Unexpected error
|
||||
Server -> Client: 500 Server error
|
||||
end
|
||||
|
||||
@enduml
|
BIN
doc/sequence-diagram/ping.png
Normal file
BIN
doc/sequence-diagram/ping.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
@ -1,2 +0,0 @@
|
||||
Client -> Server: POST /ping\nX-Server-Token: <JWT_TOKEN>\nX-Client-Token: <JWT_TOKEN>
|
||||
Server -> Client: 204 No Content
|
@ -1,36 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- Generated by SVGo -->
|
||||
<svg width="343" height="196"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'DejaVuSans';
|
||||
src: url('https://fontlibrary.org/assets/fonts/dejavu-sans/f5ec8426554a3a67ebcdd39f9c3fee83/49c0f03ec2fa354df7002bcb6331e106/DejaVuSansBook.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<line x1="45" y1="24" x2="45" y2="172" style="stroke-dasharray:8,8;stroke-width:2px;stroke:black;" />
|
||||
<rect x="8" y="8" width="75" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="24" y="29" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Client</text>
|
||||
<rect x="8" y="156" width="75" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="24" y="177" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Client</text>
|
||||
<line x1="293" y1="24" x2="293" y2="172" style="stroke-dasharray:8,8;stroke-width:2px;stroke:black;" />
|
||||
<rect x="251" y="8" width="84" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="267" y="29" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Server</text>
|
||||
<rect x="251" y="156" width="84" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="267" y="177" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Server</text>
|
||||
<rect x="61" y="56" width="216" height="46" style="fill:white;stroke:white;" />
|
||||
<text x="130" y="68" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >POST /ping</text>
|
||||
<text x="61" y="84" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >X-Server-Token: <JWT_TOKEN></text>
|
||||
<text x="63" y="100" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >X-Client-Token: <JWT_TOKEN></text>
|
||||
<line x1="45" y1="106" x2="293" y2="106" style="stroke:black;stroke-width:2px;" />
|
||||
<polyline points="284,101 293,106 284,111" style="fill:black;stroke-width:2px;stroke:black;" />
|
||||
<rect x="114" y="122" width="111" height="14" style="fill:white;stroke:white;" />
|
||||
<text x="114" y="134" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >204 No Content</text>
|
||||
<line x1="293" y1="140" x2="45" y2="140" style="stroke:black;stroke-width:2px;" />
|
||||
<polyline points="54,135 45,140 54,145" style="fill:black;stroke-width:2px;stroke:black;" />
|
||||
</svg>
|
Before Width: | Height: | Size: 2.4 KiB |
19
doc/sequence-diagram/update.plantuml
Normal file
19
doc/sequence-diagram/update.plantuml
Normal file
@ -0,0 +1,19 @@
|
||||
@startuml
|
||||
Client -> Server: POST /update\nX-Server-Token: <JWT_TOKEN>\nX-Client-Token: <JWT_TOKEN>\n\n{"Attributes": <PEER_ATTRIBUTES>}
|
||||
Server -> Server: Validate client/server tokens
|
||||
alt Success
|
||||
Server -> Server: Save attributes
|
||||
Server -> Server: Update last contact for peer ID
|
||||
Server -> Client: 200 OK {""}
|
||||
else Invalid client or server token
|
||||
Server -> Client: 400 Bad request
|
||||
else Malformed update request
|
||||
Server -> Client: 400 Bad request
|
||||
else Peer not found
|
||||
Server -> Client: 401 Unauthorized
|
||||
else Peer rejected
|
||||
Server -> Client: 403 Forbidden
|
||||
else Unexpected error
|
||||
Server -> Client: 500 Server error
|
||||
end
|
||||
@enduml
|
BIN
doc/sequence-diagram/update.png
Normal file
BIN
doc/sequence-diagram/update.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -1,2 +0,0 @@
|
||||
Client -> Server: POST /update\nX-Server-Token: <JWT_TOKEN>\nX-Client-Token: <JWT_TOKEN>\n\n{"Attributes": <PEER_ATTRIBUTES>}
|
||||
Server -> Client: 204 No Content
|
@ -1,37 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- Generated by SVGo -->
|
||||
<svg width="386" height="228"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'DejaVuSans';
|
||||
src: url('https://fontlibrary.org/assets/fonts/dejavu-sans/f5ec8426554a3a67ebcdd39f9c3fee83/49c0f03ec2fa354df7002bcb6331e106/DejaVuSansBook.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<line x1="45" y1="24" x2="45" y2="204" style="stroke-dasharray:8,8;stroke-width:2px;stroke:black;" />
|
||||
<rect x="8" y="8" width="75" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="24" y="29" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Client</text>
|
||||
<rect x="8" y="188" width="75" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="24" y="209" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Client</text>
|
||||
<line x1="336" y1="24" x2="336" y2="204" style="stroke-dasharray:8,8;stroke-width:2px;stroke:black;" />
|
||||
<rect x="294" y="8" width="84" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="310" y="29" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Server</text>
|
||||
<rect x="294" y="188" width="84" height="32" style="fill:white;stroke-width:2px;stroke:black;" />
|
||||
<text x="310" y="209" style="fill:black;font-family:DejaVuSans,sans-serif;font-size:16px;" >Server</text>
|
||||
<rect x="61" y="56" width="259" height="78" style="fill:white;stroke:white;" />
|
||||
<text x="142" y="68" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >POST /update</text>
|
||||
<text x="82" y="84" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >X-Server-Token: <JWT_TOKEN></text>
|
||||
<text x="84" y="100" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >X-Client-Token: <JWT_TOKEN></text>
|
||||
<text x="61" y="132" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >{"Attributes": <PEER_ATTRIBUTES>}</text>
|
||||
<line x1="45" y1="138" x2="336" y2="138" style="stroke:black;stroke-width:2px;" />
|
||||
<polyline points="327,133 336,138 327,143" style="fill:black;stroke-width:2px;stroke:black;" />
|
||||
<rect x="136" y="154" width="111" height="14" style="fill:white;stroke:white;" />
|
||||
<text x="136" y="166" style="font-family:DejaVuSans,sans-serif;font-size:14px;" >204 No Content</text>
|
||||
<line x1="336" y1="172" x2="45" y2="172" style="stroke:black;stroke-width:2px;" />
|
||||
<polyline points="54,167 45,172 54,177" style="fill:black;stroke-width:2px;stroke:black;" />
|
||||
</svg>
|
Before Width: | Height: | Size: 2.5 KiB |
12
go.mod
12
go.mod
@ -1,12 +1,16 @@
|
||||
module forge.cadoles.com/Cadoles/go-http-peering
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/go-chi/chi v3.3.3+incompatible
|
||||
github.com/pborman/uuid v1.2.0
|
||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90
|
||||
)
|
||||
|
||||
go 1.13
|
||||
require (
|
||||
github.com/google/uuid v1.0.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
|
||||
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect
|
||||
)
|
||||
|
||||
go 1.18
|
||||
|
12
go.sum
12
go.sum
@ -1,5 +1,3 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/go-chi/chi v3.3.3+incompatible h1:KHkmBEMNkwKuK4FdQL7N2wOeB9jnIx7jR5wsuSBEFI8=
|
||||
@ -8,7 +6,9 @@ github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2 h1:NwxKRvbkH5MsNkvOtPZi3/3kmI8CAzs3mtv+GLQMkNo=
|
||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc=
|
||||
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
|
5
misc/ci/Dockerfile
Normal file
5
misc/ci/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
FROM golang:1.19
|
||||
|
||||
RUN apt-get update && apt-get install -y make upx-ucl curl ca-certificates bash jq
|
||||
|
||||
RUN curl -k https://forge.cadoles.com/Cadoles/Jenkins/raw/branch/master/resources/com/cadoles/common/add-letsencrypt-ca.sh | bash
|
Reference in New Issue
Block a user