good morning!!!!

Skip to content
Snippets Groups Projects
Commit 8d7ec29e authored by Garet Halliday's avatar Garet Halliday
Browse files

add port to tcp

parent e2e3adb4
No related branches found
No related tags found
No related merge requests found
......@@ -9,3 +9,4 @@
target
.idea
package main
import (
"context"
"gfx.cafe/gfx/pggat/lib/config"
"gfx.cafe/gfx/pggat/lib/gat"
)
// test config, should be changed
const CONFIG = "./lib/config/config_data.toml"
func main() {
conf, err := config.Load(CONFIG)
if err != nil {
panic(err)
}
gatling := gat.NewGatling()
err = gatling.ApplyConfig(conf)
if err != nil {
panic(err)
}
err = gatling.ListenAndServe(context.Background())
if err != nil {
panic(err)
}
}
......@@ -5,6 +5,7 @@ go 1.19
require (
git.tuxpa.in/a/zlog v1.32.0
github.com/BurntSushi/toml v1.2.0
github.com/ethereum/go-ethereum v1.10.23
github.com/xdg-go/scram v1.1.1
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b
)
......
......@@ -3,6 +3,8 @@ git.tuxpa.in/a/zlog v1.32.0/go.mod h1:vUa2Qhu6DLPLqmfRy99FiPqaY2eb6/KQjtMekW3UNn
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/ethereum/go-ethereum v1.10.23 h1:Xk8XAT4/UuqcjMLIMF+7imjkg32kfVFKoeyQDaO2yWM=
github.com/ethereum/go-ethereum v1.10.23/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
......@@ -16,6 +18,7 @@ github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY=
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
......
package config
import (
"github.com/BurntSushi/toml"
"os"
)
type PoolMode string
const (
......@@ -91,3 +96,14 @@ func (o Server) Role() ServerRole {
}
return ServerRole(SERVERROLE_NONE)
}
func Load(path string) (conf *Global, err error) {
conf = new(Global)
var f []byte
f, err = os.ReadFile(path)
if err != nil {
return
}
err = toml.Unmarshal(f, conf)
return
}
......@@ -2,6 +2,7 @@ package gat
import (
"context"
"fmt"
"net"
"gfx.cafe/gfx/pggat/lib/config"
......@@ -32,7 +33,7 @@ func (g *Gatling) ApplyConfig(c *config.Global) error {
}
func (g *Gatling) ListenAndServe(ctx context.Context) error {
ln, err := net.Listen("tcp", g.c.General.Host)
ln, err := net.Listen("tcp", fmt.Sprintf("%s:%d", g.c.General.Host, g.c.General.Port))
if err != nil {
return err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment