From 8384444eeaa3f59d519cd3f8dd1a80cf74ad9a5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Josu=C3=A9=20Rodr=C3=ADguez?= Date: Tue, 1 Aug 2023 21:58:33 +0000 Subject: [PATCH] added a personalized port and tested some things around --- README.md | 15 ++++++++++++--- go.sum | 33 +++++++++++++++++++++++++++++++++ monospace.json | 2 +- vscpweb.go | 17 ++++++++++++++--- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b548a11..e1a2771 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + ## VSCPweb VSCPweb is a web based software defined networking playground that uses openvswitches (OVS) and a modified version of [mininet](https://github.com/mininet/mininet). @@ -7,7 +8,8 @@ It is a tool that allows you to: + Use linux namespace based lightweight containers as hosts or servers in the network + Monitor the health of all of the worker servers + Have CLI access to all of the hosts of the virtual network -+ Have CLI access to mininet ++ Have CLI acc +ess to mininet ## Table of Contents @@ -21,7 +23,7 @@ It is a tool that allows you to: VSCPweb is a web based network simulator that can be used to learn about and experiment with different network topologies and configurations. It is a valuable tool for anyone who wants to learn more about networking or who needs to test out new network configurations. -VSCPweb is made with golang and htmx. It uses openvswitches as the underlying network virtualization layer. This allows VSCPweb to create realistic and scalable network simulations. +VSCPweb is made with golang and htmx. It uses` openvswitches as the underlying network virtualization layer. This allows VSCPweb to create realistic and scalable network simulations. ## Installation @@ -70,4 +72,11 @@ See the LICENSE file for more information. ## Contact -If you have any questions or concerns, please contact leave an issue on GitHub. \ No newline at end of file + +## Contact + +If you have any questions or concerns, please feel free to contact us by email at [email protected] or by opening an issue on GitHub. + +We are always happy to help and we will get back to you as soon as possible. + +Thank you for using VSCPweb! \ No newline at end of file diff --git a/go.sum b/go.sum index ef2a570..e0a5e5e 100644 --- a/go.sum +++ b/go.sum @@ -4,17 +4,50 @@ github.com/keegancsmith/rpc v1.1.0 h1:bXVRk3EzbtrEegTGKxNTc+St1lR7t/Z1PAO8misBnC github.com/keegancsmith/rpc v1.1.0/go.mod h1:Xow74TKX34OPPiPCdz6x1o9c0SCxRqGxDuKGk7ZOo8s= github.com/stamblerre/gocode v1.0.0 h1:5aTRgkRTOS8mELHoKatkwhfX44OdEV3iwu3FCXyvLzk= github.com/stamblerre/gocode v1.0.0/go.mod h1:ONyGamdxpnxaG2+XLyGkNuuoYISmz0QFVHScxvsXsqM= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab h1:tpc/nJ4vD66vAk/2KN0sw/DvQIz2sKmCpWvyKtPmfMQ= golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/monospace.json b/monospace.json index 2b03351..2ff71ff 100644 --- a/monospace.json +++ b/monospace.json @@ -1,7 +1,7 @@ { "previews": [ { - "command": ["./getter.sh;","go","run","vscpweb.go"], + "command": ["go","run","vscpweb.go", "--port", "$PORT"], "id": "web", "manager": "web" } diff --git a/vscpweb.go b/vscpweb.go index 5a3f2dd..d4c3ad3 100644 --- a/vscpweb.go +++ b/vscpweb.go @@ -4,9 +4,12 @@ package main import ( + "flag" "fmt" "html/template" + "math/rand" "net/http" + "strconv" hh "healthHandlers" //mh "managementHandlers" @@ -28,7 +31,12 @@ func main() { s.Router.Handle("/static/*", http.StripPrefix("/static/", fs)) //staring up the server: - http.ListenAndServe(":8001", s.Router) + port := flag.Int("port", 8001, "Port in which the server will be started") + flag.Parse() + setPort := strconv.Itoa(*port) + setPort = ":"+setPort + + http.ListenAndServe(setPort , s.Router) } type server struct { @@ -134,8 +142,11 @@ func (s *server) MountHandlers() { // GenericHandler404 is the universal 404 response of this front end func GenericHandler404(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(404) - w.Write([]byte("route does not exist")) + +w.WriteHeader(404) + messages := []string{"route does not exist", "page not found", "resource not found"} + randomIndex := rand.Intn(len(messages)) + w.Write([]byte(messages[randomIndex])) } // GenericHandler405 is the universal 405 response of this front end -- 2.25.1