Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SysDistribueTPGnutella
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ivan.rigo
SysDistribueTPGnutella
Commits
0b302e41
Commit
0b302e41
authored
2 years ago
by
ivan.rigo
Browse files
Options
Downloads
Patches
Plain Diff
Added Yaml, need more fix and doc
parent
daf38887
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
web-service-gin/Gnutella.go
+34
-12
34 additions, 12 deletions
web-service-gin/Gnutella.go
web-service-gin/go.mod
+1
-0
1 addition, 0 deletions
web-service-gin/go.mod
web-service-gin/go.sum
+2
-0
2 additions, 0 deletions
web-service-gin/go.sum
with
37 additions
and
12 deletions
web-service-gin/Gnutella.go
+
34
−
12
View file @
0b302e41
...
@@ -11,10 +11,24 @@ import (
...
@@ -11,10 +11,24 @@ import (
"sync"
"sync"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"gopkg.in/yaml.v2"
)
)
type
nodeData
struct
{
ID
int
`yaml:"id"`
Address
string
`yaml:"address"`
Neighbours
[]
Neighbors
`yaml:"neighbors"`
}
type
Neighbors
struct
{
ID
int
`yaml:"id"`
Address
string
`yaml:"address"`
}
var
data
nodeData
var
storage
[]
string
var
storage
[]
string
var
idServ
string
var
idServ
string
var
addressCur
string
var
transmitter
int
var
transmitter
int
var
msgId
=
0
var
msgId
=
0
var
err
error
var
err
error
...
@@ -123,25 +137,33 @@ func foundReq(c *gin.Context) {
...
@@ -123,25 +137,33 @@ func foundReq(c *gin.Context) {
func
printErr
(
err
error
)
{
func
printErr
(
err
error
)
{
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
os
.
Exit
(
1
)
}
}
}
}
func
main
()
{
func
main
()
{
idServ
=
os
.
Args
[
1
]
neighborsFile
:
=
os
.
Args
[
1
]
idServ
=
os
.
Args
[
2
]
nbIdServ
,
err
:=
strconv
.
Atoi
(
idServ
)
buf
,
err
:=
ioutil
.
ReadFile
(
neighborsFile
)
files
,
err
:
=
ioutil
.
ReadDir
(
"Storage"
+
idServ
+
"/"
)
err
=
yaml
.
Unmarshal
(
buf
,
&
data
)
printErr
(
err
)
printErr
(
err
)
addressCur
=
data
.
Address
for
_
,
file
:=
range
files
{
/*
storage
=
append
(
storage
,
file
.
Name
())
nbIdServ, err := strconv.Atoi(idServ)
}
files, err := ioutil.ReadDir("Storage" + idServ + "/")
printErr(err)
for _, file := range files {
storage = append(storage, file.Name())
}
router
:=
gin
.
Default
()
router := gin.Default()
router
.
GET
(
"/initReq/:tlv/:ressource"
,
initReq
)
router.GET("/initReq/:tlv/:ressource", initReq)
router
.
GET
(
"/req/:transmitter/:tlv/:msgId/:ressource"
,
receiveReq
)
router.GET("/req/:transmitter/:tlv/:msgId/:ressource", receiveReq)
router
.
GET
(
"/foundReq/:finder/:ressource"
,
foundReq
)
router.GET("/foundReq/:finder/:ressource", foundReq)
router
.
Run
(
"localhost:"
+
strconv
.
Itoa
(
basePort
+
nbIdServ
))
router.Run("localhost:" + strconv.Itoa(basePort+nbIdServ))
*/
}
}
This diff is collapsed.
Click to expand it.
web-service-gin/go.mod
+
1
−
0
View file @
0b302e41
...
@@ -23,4 +23,5 @@ require (
...
@@ -23,4 +23,5 @@ require (
golang.org/x/text v0.3.6 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
)
This diff is collapsed.
Click to expand it.
web-service-gin/go.sum
+
2
−
0
View file @
0b302e41
...
@@ -73,3 +73,5 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
...
@@ -73,3 +73,5 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment