diff options
author | Valery Piashchynski <[email protected]> | 2021-08-11 11:45:24 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-08-11 11:45:24 +0300 |
commit | 3e2e9fbd9650c44d57a41a9dc702fe93aad2b77f (patch) | |
tree | 38f25c3c0679e8510b896d001d1b7dccf21c4bd8 | |
parent | d449d9d5aec1eec6d494064299feb1551f88ffe2 (diff) |
Replace all 'localhost' with '127.0.0.1'. Fix default configuration and
other small bugs.
Signed-off-by: Valery Piashchynski <[email protected]>
63 files changed, 647 insertions, 172 deletions
diff --git a/pkg/transport/socket/socket_factory_spawn_test.go b/pkg/transport/socket/socket_factory_spawn_test.go index 23506291..905a3b6b 100644 --- a/pkg/transport/socket/socket_factory_spawn_test.go +++ b/pkg/transport/socket/socket_factory_spawn_test.go @@ -16,7 +16,7 @@ import ( ) func Test_Tcp_Start2(t *testing.T) { - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { errC := ls.Close() @@ -45,7 +45,7 @@ func Test_Tcp_Start2(t *testing.T) { } func Test_Tcp_StartCloseFactory2(t *testing.T) { - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { } else { t.Skip("socket is busy") @@ -72,7 +72,7 @@ func Test_Tcp_StartCloseFactory2(t *testing.T) { } func Test_Tcp_StartError2(t *testing.T) { - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { errC := ls.Close() @@ -96,7 +96,7 @@ func Test_Tcp_StartError2(t *testing.T) { } func Test_Tcp_Failboot2(t *testing.T) { - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { err3 := ls.Close() @@ -128,7 +128,7 @@ func Test_Tcp_Failboot2(t *testing.T) { } func Test_Tcp_Invalid2(t *testing.T) { - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { errC := ls.Close() @@ -148,7 +148,7 @@ func Test_Tcp_Invalid2(t *testing.T) { } func Test_Tcp_Broken2(t *testing.T) { - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { errC := ls.Close() @@ -202,7 +202,7 @@ func Test_Tcp_Broken2(t *testing.T) { } func Test_Tcp_Echo2(t *testing.T) { - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { errC := ls.Close() diff --git a/pkg/transport/socket/socket_factory_test.go b/pkg/transport/socket/socket_factory_test.go index 91da595d..f9bb2178 100755 --- a/pkg/transport/socket/socket_factory_test.go +++ b/pkg/transport/socket/socket_factory_test.go @@ -19,7 +19,7 @@ func Test_Tcp_Start(t *testing.T) { ctx := context.Background() time.Sleep(time.Millisecond * 10) // to ensure free socket - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { err = ls.Close() @@ -50,7 +50,7 @@ func Test_Tcp_Start(t *testing.T) { func Test_Tcp_StartCloseFactory(t *testing.T) { time.Sleep(time.Millisecond * 10) // to ensure free socket ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { } else { t.Skip("socket is busy") @@ -79,7 +79,7 @@ func Test_Tcp_StartCloseFactory(t *testing.T) { func Test_Tcp_StartError(t *testing.T) { time.Sleep(time.Millisecond * 10) // to ensure free socket ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { err = ls.Close() @@ -106,7 +106,7 @@ func Test_Tcp_Failboot(t *testing.T) { time.Sleep(time.Millisecond * 10) // to ensure free socket ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { err3 := ls.Close() @@ -140,7 +140,7 @@ func Test_Tcp_Failboot(t *testing.T) { func Test_Tcp_Timeout(t *testing.T) { time.Sleep(time.Millisecond * 10) // to ensure free socket ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { err = ls.Close() @@ -163,7 +163,7 @@ func Test_Tcp_Timeout(t *testing.T) { func Test_Tcp_Invalid(t *testing.T) { time.Sleep(time.Millisecond * 10) // to ensure free socket ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { err = ls.Close() @@ -185,7 +185,7 @@ func Test_Tcp_Invalid(t *testing.T) { func Test_Tcp_Broken(t *testing.T) { time.Sleep(time.Millisecond * 10) // to ensure free socket ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { errC := ls.Close() @@ -241,7 +241,7 @@ func Test_Tcp_Broken(t *testing.T) { func Test_Tcp_Echo(t *testing.T) { time.Sleep(time.Millisecond * 10) // to ensure free socket ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if assert.NoError(t, err) { defer func() { err = ls.Close() @@ -485,7 +485,7 @@ func Test_Unix_Echo(t *testing.T) { func Benchmark_Tcp_SpawnWorker_Stop(b *testing.B) { ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if err == nil { defer func() { err = ls.Close() @@ -518,7 +518,7 @@ func Benchmark_Tcp_SpawnWorker_Stop(b *testing.B) { func Benchmark_Tcp_Worker_ExecEcho(b *testing.B) { ctx := context.Background() - ls, err := net.Listen("tcp", "localhost:9007") + ls, err := net.Listen("tcp", "127.0.0.1:9007") if err == nil { defer func() { err = ls.Close() diff --git a/plugins/http/config/ssl.go b/plugins/http/config/ssl.go index d44703f9..0e3c0caf 100644 --- a/plugins/http/config/ssl.go +++ b/plugins/http/config/ssl.go @@ -36,7 +36,7 @@ func (s *SSL) Valid() error { parts := strings.Split(s.Address, ":") switch len(parts) { // :443 form - // localhost:443 form + // 127.0.0.1:443 form // use 0.0.0.0 as host and 443 as port case 2: if parts[0] == "" { diff --git a/plugins/http/config/ssl_config_test.go b/plugins/http/config/ssl_config_test.go index 1f5fef0a..8f6cf40e 100644 --- a/plugins/http/config/ssl_config_test.go +++ b/plugins/http/config/ssl_config_test.go @@ -101,7 +101,7 @@ func TestSSL_Valid6(t *testing.T) { func TestSSL_Valid7(t *testing.T) { conf := &SSL{ - Address: "localhost:555:1", + Address: "127.0.0.1:555:1", Redirect: false, Key: "../../../tests/plugins/http/fixtures/server.key", Cert: "../../../tests/plugins/http/fixtures/server.crt", diff --git a/plugins/jobs/drivers/amqp/config.go b/plugins/jobs/drivers/amqp/config.go index 37f5c1c4..3fb0d066 100644 --- a/plugins/jobs/drivers/amqp/config.go +++ b/plugins/jobs/drivers/amqp/config.go @@ -57,6 +57,6 @@ func (c *Config) InitDefault() { func (c *GlobalCfg) InitDefault() { if c.Addr == "" { - c.Addr = "amqp://guest:guest@localhost:5672/" + c.Addr = "amqp://guest:[email protected]:5672/" } } diff --git a/plugins/jobs/drivers/amqp/consumer.go b/plugins/jobs/drivers/amqp/consumer.go index 36a16bcd..d7425858 100644 --- a/plugins/jobs/drivers/amqp/consumer.go +++ b/plugins/jobs/drivers/amqp/consumer.go @@ -181,7 +181,7 @@ func FromPipeline(pipeline *pipeline.Pipeline, log logger.Logger, cfg config.Con exchangeName: pipeline.String(exchangeKey, "amqp.default"), prefetch: pipeline.Int(prefetch, 10), priority: int64(pipeline.Int(priority, 10)), - exclusive: pipeline.Bool(exclusive, true), + exclusive: pipeline.Bool(exclusive, false), multipleAck: pipeline.Bool(multipleAsk, false), requeueOnFail: pipeline.Bool(requeueOnFail, false), requeueCh: make(chan *Item, 1000), diff --git a/plugins/jobs/drivers/beanstalk/config.go b/plugins/jobs/drivers/beanstalk/config.go index f0012362..a8069f5d 100644 --- a/plugins/jobs/drivers/beanstalk/config.go +++ b/plugins/jobs/drivers/beanstalk/config.go @@ -1,6 +1,10 @@ package beanstalk -import "time" +import ( + "time" + + "github.com/spiral/roadrunner/v2/utils" +) const ( tubePriority string = "tube_priority" @@ -15,7 +19,7 @@ type GlobalCfg struct { func (c *GlobalCfg) InitDefault() { if c.Addr == "" { - c.Addr = "tcp://localhost:11300" + c.Addr = "tcp://127.0.0.1:11300" } if c.Timeout == 0 { @@ -25,7 +29,7 @@ func (c *GlobalCfg) InitDefault() { type Config struct { PipePriority int64 `mapstructure:"priority"` - TubePriority uint32 `mapstructure:"tube_priority"` + TubePriority *uint32 `mapstructure:"tube_priority"` Tube string `mapstructure:"tube"` ReserveTimeout time.Duration `mapstructure:"reserve_timeout"` } @@ -39,6 +43,10 @@ func (c *Config) InitDefault() { c.ReserveTimeout = time.Second * 1 } + if c.TubePriority == nil { + c.TubePriority = utils.Uint32(0) + } + if c.PipePriority == 0 { c.PipePriority = 10 } diff --git a/plugins/jobs/drivers/beanstalk/consumer.go b/plugins/jobs/drivers/beanstalk/consumer.go index b57b22ac..21b05b16 100644 --- a/plugins/jobs/drivers/beanstalk/consumer.go +++ b/plugins/jobs/drivers/beanstalk/consumer.go @@ -14,6 +14,7 @@ import ( "github.com/spiral/roadrunner/v2/plugins/jobs/job" "github.com/spiral/roadrunner/v2/plugins/jobs/pipeline" "github.com/spiral/roadrunner/v2/plugins/logger" + "github.com/spiral/roadrunner/v2/utils" ) type JobConsumer struct { @@ -33,7 +34,7 @@ type JobConsumer struct { tout time.Duration // tube name tName string - tubePriority uint32 + tubePriority *uint32 priority int64 stopCh chan struct{} @@ -65,7 +66,7 @@ func NewBeanstalkConsumer(configKey string, log logger.Logger, cfg config.Config dsn := strings.Split(globalCfg.Addr, "://") if len(dsn) != 2 { - return nil, errors.E(op, errors.Errorf("invalid socket DSN (tcp://localhost:11300, unix://beanstalk.sock), provided: %s", globalCfg.Addr)) + return nil, errors.E(op, errors.Errorf("invalid socket DSN (tcp://127.0.0.1:11300, unix://beanstalk.sock), provided: %s", globalCfg.Addr)) } cPool, err := NewConnPool(dsn[0], dsn[1], pipeCfg.Tube, globalCfg.Timeout, log) @@ -115,7 +116,7 @@ func FromPipeline(pipe *pipeline.Pipeline, log logger.Logger, cfg config.Configu dsn := strings.Split(globalCfg.Addr, "://") if len(dsn) != 2 { - return nil, errors.E(op, errors.Errorf("invalid socket DSN (tcp://localhost:11300, unix://beanstalk.sock), provided: %s", globalCfg.Addr)) + return nil, errors.E(op, errors.Errorf("invalid socket DSN (tcp://127.0.0.1:11300, unix://beanstalk.sock), provided: %s", globalCfg.Addr)) } cPool, err := NewConnPool(dsn[0], dsn[1], pipe.String(tube, "default"), globalCfg.Timeout, log) @@ -134,7 +135,7 @@ func FromPipeline(pipe *pipeline.Pipeline, log logger.Logger, cfg config.Configu tout: globalCfg.Timeout, tName: pipe.String(tube, "default"), reserveTimeout: time.Second * time.Duration(pipe.Int(reserveTimeout, 5)), - tubePriority: uint32(pipe.Int(tubePriority, 0)), + tubePriority: utils.Uint32(uint32(pipe.Int(tubePriority, 1))), priority: pipe.Priority(), // buffered with two because jobs root plugin can call Stop at the same time as Pause @@ -190,7 +191,7 @@ func (j *JobConsumer) handleItem(ctx context.Context, item *Item) error { // <ttr> seconds, the job will time out and the server will release the job. // The minimum ttr is 1. If the client sends 0, the server will silently // increase the ttr to 1. Maximum ttr is 2**32-1. - id, err := j.pool.Put(ctx, bb.Bytes(), j.tubePriority, item.Options.DelayDuration(), item.Options.TimeoutDuration()) + id, err := j.pool.Put(ctx, bb.Bytes(), *j.tubePriority, item.Options.DelayDuration(), item.Options.TimeoutDuration()) if err != nil { errD := j.pool.Delete(ctx, id) if errD != nil { diff --git a/plugins/jobs/drivers/ephemeral/consumer.go b/plugins/jobs/drivers/ephemeral/consumer.go index 050d74b9..52c2cf65 100644 --- a/plugins/jobs/drivers/ephemeral/consumer.go +++ b/plugins/jobs/drivers/ephemeral/consumer.go @@ -180,7 +180,7 @@ func (j *JobConsumer) Pause(_ context.Context, pipeline string) { } j.eh.Push(events.JobEvent{ - Event: events.EventPipeStopped, + Event: events.EventPipePaused, Pipeline: pipeline, Start: time.Now(), Elapsed: 0, diff --git a/plugins/jobs/drivers/sqs/config.go b/plugins/jobs/drivers/sqs/config.go index 39d0af48..9b2a1ca8 100644 --- a/plugins/jobs/drivers/sqs/config.go +++ b/plugins/jobs/drivers/sqs/config.go @@ -87,7 +87,7 @@ type Config struct { func (c *GlobalCfg) InitDefault() { if c.Endpoint == "" { - c.Endpoint = "http://localhost:9324" + c.Endpoint = "http://127.0.0.1:9324" } } diff --git a/plugins/jobs/drivers/sqs/item.go b/plugins/jobs/drivers/sqs/item.go index ea4ac8b7..cd2f6104 100644 --- a/plugins/jobs/drivers/sqs/item.go +++ b/plugins/jobs/drivers/sqs/item.go @@ -25,7 +25,6 @@ var itemAttributes = []string{ job.RRDelay, job.RRTimeout, job.RRPriority, - job.RRMaxAttempts, } type Item struct { diff --git a/plugins/kv/drivers/memcached/config.go b/plugins/kv/drivers/memcached/config.go index 7aad53b6..6d413790 100644 --- a/plugins/kv/drivers/memcached/config.go +++ b/plugins/kv/drivers/memcached/config.go @@ -7,6 +7,6 @@ type Config struct { func (s *Config) InitDefaults() { if s.Addr == nil { - s.Addr = []string{"localhost:11211"} // default url for memcached + s.Addr = []string{"127.0.0.1:11211"} // default url for memcached } } diff --git a/plugins/kv/plugin.go b/plugins/kv/plugin.go index e9ea25df..53fade97 100644 --- a/plugins/kv/plugin.go +++ b/plugins/kv/plugin.go @@ -80,7 +80,7 @@ func (p *Plugin) Serve() chan error { //nolint:gocognit memcached: driver: memcached - addr: [ "localhost:11211" ] + addr: [ "127.0.0.1:11211" ] For this config we should have 3 constructors: memory, boltdb and memcached but 4 KVs: default, boltdb-south, boltdb-north and memcached diff --git a/plugins/metrics/config.go b/plugins/metrics/config.go index dd36005e..a2835130 100644 --- a/plugins/metrics/config.go +++ b/plugins/metrics/config.go @@ -135,6 +135,6 @@ func (c *Config) getCollectors() (map[string]prometheus.Collector, error) { func (c *Config) InitDefaults() { if c.Address == "" { - c.Address = "localhost:2112" + c.Address = "127.0.0.1:2112" } } diff --git a/plugins/redis/config.go b/plugins/redis/config.go index 41348236..9acb4b47 100644 --- a/plugins/redis/config.go +++ b/plugins/redis/config.go @@ -29,6 +29,6 @@ type Config struct { // InitDefaults initializing fill config with default values func (s *Config) InitDefaults() { if s.Addrs == nil { - s.Addrs = []string{"localhost:6379"} // default addr is pointing to local storage + s.Addrs = []string{"127.0.0.1:6379"} // default addr is pointing to local storage } } diff --git a/tests/client.php b/tests/client.php index c00cece1..d67f6937 100644 --- a/tests/client.php +++ b/tests/client.php @@ -17,7 +17,7 @@ switch ($goridge) { break; case "tcp": - $relay = new Goridge\SocketRelay("localhost", 9007); + $relay = new Goridge\SocketRelay("127.0.0.1", 9007); break; case "unix": diff --git a/tests/env/docker-compose.yaml b/tests/env/docker-compose.yaml index dc91e7b6..4f58d543 100644 --- a/tests/env/docker-compose.yaml +++ b/tests/env/docker-compose.yaml @@ -4,15 +4,15 @@ services: memcached: image: memcached:latest ports: - - "0.0.0.0:11211:11211" + - "127.0.0.1:11211:11211" redis: image: redis:6 ports: - - "6379:6379" + - "127.0.0.1:6379:6379" redis2: image: redis:6 ports: - - "6378:6379" + - "127.0.0.1:6378:6379" toxicproxy: image: shopify/toxiproxy @@ -23,17 +23,17 @@ services: context: . dockerfile: Dockerfile-beanstalkd.yaml ports: - - "11300:11300" + - "127.0.0.1:11300:11300" sqs: build: context: . dockerfile: Dockerfile-elastic-mq.yaml ports: - - "9324:9324" + - "127.0.0.1:9324:9324" rabbitmq: image: rabbitmq:3-management ports: - - "15672:15672" - - "5672:5672" + - "127.0.0.1:15672:15672" + - "127.0.0.1:5672:5672" diff --git a/tests/http/client.php b/tests/http/client.php index ad5cce24..90b5c2b5 100644 --- a/tests/http/client.php +++ b/tests/http/client.php @@ -18,7 +18,7 @@ switch ($goridge) { break; case "tcp": - $relay = new Goridge\SocketRelay("localhost", 9007); + $relay = new Goridge\SocketRelay("127.0.0.1", 9007); break; case "unix": diff --git a/tests/http/slow-client.php b/tests/http/slow-client.php index 731232f7..1eaa7bc8 100644 --- a/tests/http/slow-client.php +++ b/tests/http/slow-client.php @@ -19,7 +19,7 @@ switch ($goridge) { break; case "tcp": - $relay = new Goridge\SocketRelay("localhost", 9007); + $relay = new Goridge\SocketRelay("127.0.0.1", 9007); break; case "unix": diff --git a/tests/plugins/broadcast/configs/.rr-broadcast-global.yaml b/tests/plugins/broadcast/configs/.rr-broadcast-global.yaml index ea25988c..5ae5a101 100644 --- a/tests/plugins/broadcast/configs/.rr-broadcast-global.yaml +++ b/tests/plugins/broadcast/configs/.rr-broadcast-global.yaml @@ -19,7 +19,7 @@ http: redis: addrs: - - "localhost:6379" + - "127.0.0.1:6379" broadcast: test: @@ -27,7 +27,7 @@ broadcast: test2: driver: redis addrs: - - "localhost:6378" + - "127.0.0.1:6378" test3: driver: memory test4: diff --git a/tests/plugins/broadcast/configs/.rr-broadcast-init.yaml b/tests/plugins/broadcast/configs/.rr-broadcast-init.yaml index aa80330e..d8457578 100644 --- a/tests/plugins/broadcast/configs/.rr-broadcast-init.yaml +++ b/tests/plugins/broadcast/configs/.rr-broadcast-init.yaml @@ -23,7 +23,7 @@ broadcast: default: driver: redis addrs: - - "localhost:6379" + - "127.0.0.1:6379" logs: mode: development diff --git a/tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml b/tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml index cbe18196..2337b8fe 100644 --- a/tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml +++ b/tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml @@ -21,11 +21,11 @@ broadcast: test: driver: redis addrs: - - "localhost:6379" + - "127.0.0.1:6379" test2: driver: redis addrs: - - "localhost:6378" + - "127.0.0.1:6378" test3: driver: memory test4: diff --git a/tests/plugins/config/config_test.go b/tests/plugins/config/config_test.go index b6063cec..87ab1eaa 100755 --- a/tests/plugins/config/config_test.go +++ b/tests/plugins/config/config_test.go @@ -97,7 +97,7 @@ func TestConfigOverwriteValid(t *testing.T) { vp := &config.Viper{} vp.Path = "configs/.rr.yaml" vp.Prefix = "rr" - vp.Flags = []string{"rpc.listen=tcp://localhost:36643"} + vp.Flags = []string{"rpc.listen=tcp://127.0.0.1:36643"} err = container.RegisterAll( &logger.ZapLogger{}, @@ -143,7 +143,7 @@ func TestConfigEnvVariables(t *testing.T) { t.Fatal(err) } - err = os.Setenv("SUPER_RPC_ENV", "tcp://localhost:36643") + err = os.Setenv("SUPER_RPC_ENV", "tcp://127.0.0.1:36643") assert.NoError(t, err) vp := &config.Viper{} @@ -194,7 +194,7 @@ func TestConfigEnvVariablesFail(t *testing.T) { t.Fatal(err) } - err = os.Setenv("SUPER_RPC_ENV", "tcp://localhost:6065") + err = os.Setenv("SUPER_RPC_ENV", "tcp://127.0.0.1:6065") assert.NoError(t, err) vp := &config.Viper{} diff --git a/tests/plugins/config/configs/.rr.yaml b/tests/plugins/config/configs/.rr.yaml index f449dcf3..575cdd33 100755 --- a/tests/plugins/config/configs/.rr.yaml +++ b/tests/plugins/config/configs/.rr.yaml @@ -1,5 +1,5 @@ rpc: - listen: tcp://localhost:6060 + listen: tcp://127.0.0.1:6060 logs: mode: development diff --git a/tests/plugins/config/plugin1.go b/tests/plugins/config/plugin1.go index 1de9a02e..08a48a4f 100755 --- a/tests/plugins/config/plugin1.go +++ b/tests/plugins/config/plugin1.go @@ -83,7 +83,7 @@ func (f *Foo) Serve() chan error { return errCh } - if allCfg.RPC.Listen != "tcp://localhost:6060" { + if allCfg.RPC.Listen != "tcp://127.0.0.1:6060" { errCh <- errors.E(op, errors.Str("RPC.Listen should be parsed")) return errCh } diff --git a/tests/plugins/config/plugin2.go b/tests/plugins/config/plugin2.go index 9639b170..8c6f36c1 100755 --- a/tests/plugins/config/plugin2.go +++ b/tests/plugins/config/plugin2.go @@ -37,7 +37,7 @@ func (f *Foo2) Serve() chan error { return errCh } - if allCfg.RPC.Listen != "tcp://localhost:36643" { + if allCfg.RPC.Listen != "tcp://127.0.0.1:36643" { errCh <- errors.E(op, errors.Str("RPC.Listen should be overwritten")) return errCh } diff --git a/tests/plugins/gzip/plugin_test.go b/tests/plugins/gzip/plugin_test.go index b254fad5..5612ec94 100644 --- a/tests/plugins/gzip/plugin_test.go +++ b/tests/plugins/gzip/plugin_test.go @@ -89,7 +89,7 @@ func TestGzipPlugin(t *testing.T) { } func headerCheck(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:18953", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:18953", nil) assert.NoError(t, err) client := &http.Client{ Transport: &http.Transport{ diff --git a/tests/plugins/headers/headers_plugin_test.go b/tests/plugins/headers/headers_plugin_test.go index 49d86b00..a03a3c34 100644 --- a/tests/plugins/headers/headers_plugin_test.go +++ b/tests/plugins/headers/headers_plugin_test.go @@ -154,7 +154,7 @@ func TestRequestHeaders(t *testing.T) { } func reqHeaders(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:22655?hello=value", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:22655?hello=value", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -239,7 +239,7 @@ func TestResponseHeaders(t *testing.T) { } func resHeaders(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:22455?hello=value", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:22455?hello=value", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -326,7 +326,7 @@ func TestCORSHeaders(t *testing.T) { } func corsHeadersPass(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:22855", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:22855", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -346,7 +346,7 @@ func corsHeadersPass(t *testing.T) { } func corsHeaders(t *testing.T) { - req, err := http.NewRequest("OPTIONS", "http://localhost:22855", nil) + req, err := http.NewRequest("OPTIONS", "http://127.0.0.1:22855", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) diff --git a/tests/plugins/http/handler_test.go b/tests/plugins/http/handler_test.go index 37d9452c..c8709678 100644 --- a/tests/plugins/http/handler_test.go +++ b/tests/plugins/http/handler_test.go @@ -56,7 +56,7 @@ func TestHandler_Echo(t *testing.T) { }(hs) time.Sleep(time.Millisecond * 10) - body, r, err := get("http://localhost:8177/?hello=world") + body, r, err := get("http://127.0.0.1:8177/?hello=world") assert.NoError(t, err) defer func() { _ = r.Body.Close() @@ -111,7 +111,7 @@ func TestHandler_Headers(t *testing.T) { }() time.Sleep(time.Millisecond * 100) - req, err := http.NewRequest("GET", "http://localhost:8078?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:8078?hello=world", nil) assert.NoError(t, err) req.Header.Add("input", "sample") @@ -172,7 +172,7 @@ func TestHandler_Empty_User_Agent(t *testing.T) { }() time.Sleep(time.Millisecond * 10) - req, err := http.NewRequest("GET", "http://localhost:19658?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:19658?hello=world", nil) assert.NoError(t, err) req.Header.Add("user-agent", "") @@ -232,7 +232,7 @@ func TestHandler_User_Agent(t *testing.T) { }() time.Sleep(time.Millisecond * 10) - req, err := http.NewRequest("GET", "http://localhost:25688?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:25688?hello=world", nil) assert.NoError(t, err) req.Header.Add("User-Agent", "go-agent") @@ -292,7 +292,7 @@ func TestHandler_Cookies(t *testing.T) { }() time.Sleep(time.Millisecond * 10) - req, err := http.NewRequest("GET", "http://localhost:8079", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:8079", nil) assert.NoError(t, err) req.AddCookie(&http.Cookie{Name: "input", Value: "input-value"}) @@ -359,7 +359,7 @@ func TestHandler_JsonPayload_POST(t *testing.T) { req, err := http.NewRequest( "POST", - "http://localhost"+hs.Addr, + "http://127.0.0.1"+hs.Addr, bytes.NewBufferString(`{"key":"value"}`), ) assert.NoError(t, err) @@ -421,7 +421,7 @@ func TestHandler_JsonPayload_PUT(t *testing.T) { }() time.Sleep(time.Millisecond * 10) - req, err := http.NewRequest("PUT", "http://localhost"+hs.Addr, bytes.NewBufferString(`{"key":"value"}`)) + req, err := http.NewRequest("PUT", "http://127.0.0.1"+hs.Addr, bytes.NewBufferString(`{"key":"value"}`)) assert.NoError(t, err) req.Header.Add("Content-Type", "application/json") @@ -481,7 +481,7 @@ func TestHandler_JsonPayload_PATCH(t *testing.T) { }() time.Sleep(time.Millisecond * 10) - req, err := http.NewRequest("PATCH", "http://localhost"+hs.Addr, bytes.NewBufferString(`{"key":"value"}`)) + req, err := http.NewRequest("PATCH", "http://127.0.0.1"+hs.Addr, bytes.NewBufferString(`{"key":"value"}`)) assert.NoError(t, err) req.Header.Add("Content-Type", "application/json") @@ -552,7 +552,7 @@ func TestHandler_FormData_POST(t *testing.T) { form.Add("arr[c]p", "l") form.Add("arr[c]z", "") - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, strings.NewReader(form.Encode())) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, strings.NewReader(form.Encode())) assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") @@ -626,7 +626,7 @@ func TestHandler_FormData_POST_Overwrite(t *testing.T) { form.Add("arr[c]p", "l") form.Add("arr[c]z", "") - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, strings.NewReader(form.Encode())) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, strings.NewReader(form.Encode())) assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") @@ -698,7 +698,7 @@ func TestHandler_FormData_POST_Form_UrlEncoded_Charset(t *testing.T) { form.Add("arr[c]p", "l") form.Add("arr[c]z", "") - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, strings.NewReader(form.Encode())) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, strings.NewReader(form.Encode())) assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") @@ -770,7 +770,7 @@ func TestHandler_FormData_PUT(t *testing.T) { form.Add("arr[c]p", "l") form.Add("arr[c]z", "") - req, err := http.NewRequest("PUT", "http://localhost"+hs.Addr, strings.NewReader(form.Encode())) + req, err := http.NewRequest("PUT", "http://127.0.0.1"+hs.Addr, strings.NewReader(form.Encode())) assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") @@ -842,7 +842,7 @@ func TestHandler_FormData_PATCH(t *testing.T) { form.Add("arr[c]p", "l") form.Add("arr[c]z", "") - req, err := http.NewRequest("PATCH", "http://localhost"+hs.Addr, strings.NewReader(form.Encode())) + req, err := http.NewRequest("PATCH", "http://127.0.0.1"+hs.Addr, strings.NewReader(form.Encode())) assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") @@ -956,7 +956,7 @@ func TestHandler_Multipart_POST(t *testing.T) { t.Errorf("error closing the writer: error %v", err) } - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, &mb) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) @@ -1070,7 +1070,7 @@ func TestHandler_Multipart_PUT(t *testing.T) { t.Errorf("error closing the writer: error %v", err) } - req, err := http.NewRequest("PUT", "http://localhost"+hs.Addr, &mb) + req, err := http.NewRequest("PUT", "http://127.0.0.1"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) @@ -1186,7 +1186,7 @@ func TestHandler_Multipart_PATCH(t *testing.T) { t.Errorf("error closing the writer: error %v", err) } - req, err := http.NewRequest("PATCH", "http://localhost"+hs.Addr, &mb) + req, err := http.NewRequest("PATCH", "http://127.0.0.1"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) @@ -1247,7 +1247,7 @@ func TestHandler_Error(t *testing.T) { }() time.Sleep(time.Millisecond * 10) - _, r, err := get("http://localhost:8177/?hello=world") + _, r, err := get("http://127.0.0.1:8177/?hello=world") assert.NoError(t, err) defer func() { _ = r.Body.Close() @@ -1293,7 +1293,7 @@ func TestHandler_Error2(t *testing.T) { }() time.Sleep(time.Millisecond * 10) - _, r, err := get("http://localhost:8177/?hello=world") + _, r, err := get("http://127.0.0.1:8177/?hello=world") assert.NoError(t, err) defer func() { _ = r.Body.Close() @@ -1344,7 +1344,7 @@ func TestHandler_Error3(t *testing.T) { b2.Write([]byte(" ")) } - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, b2) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, b2) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -1409,7 +1409,7 @@ func TestHandler_ResponseDuration(t *testing.T) { } }) - body, r, err := get("http://localhost:8177/?hello=world") + body, r, err := get("http://127.0.0.1:8177/?hello=world") assert.NoError(t, err) defer func() { _ = r.Body.Close() @@ -1470,7 +1470,7 @@ func TestHandler_ResponseDurationDelayed(t *testing.T) { } }) - body, r, err := get("http://localhost:8177/?hello=world") + body, r, err := get("http://127.0.0.1:8177/?hello=world") assert.NoError(t, err) defer func() { _ = r.Body.Close() @@ -1530,7 +1530,7 @@ func TestHandler_ErrorDuration(t *testing.T) { } }) - _, r, err := get("http://localhost:8177/?hello=world") + _, r, err := get("http://127.0.0.1:8177/?hello=world") assert.NoError(t, err) defer func() { _ = r.Body.Close() @@ -1838,7 +1838,7 @@ func BenchmarkHandler_Listen_Echo(b *testing.B) { b.ReportAllocs() bb := "WORLD" for n := 0; n < b.N; n++ { - r, err := http.Get("http://localhost:8177/?hello=world") + r, err := http.Get("http://127.0.0.1:8177/?hello=world") if err != nil { b.Fail() } diff --git a/tests/plugins/http/http_plugin_test.go b/tests/plugins/http/http_plugin_test.go index a6c75038..db62781f 100644 --- a/tests/plugins/http/http_plugin_test.go +++ b/tests/plugins/http/http_plugin_test.go @@ -251,7 +251,7 @@ func TestHTTPInformerReset(t *testing.T) { } func echoHTTP(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:10084?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:10084?hello=world", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -371,7 +371,7 @@ func TestSSL(t *testing.T) { } func sslNoRedirect(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:8085?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:8085?hello=world", nil) assert.NoError(t, err) r, err := sslClient.Do(req) @@ -393,7 +393,7 @@ func sslNoRedirect(t *testing.T) { } func sslEcho(t *testing.T) { - req, err := http.NewRequest("GET", "https://localhost:8893?hello=world", nil) + req, err := http.NewRequest("GET", "https://127.0.0.1:8893?hello=world", nil) assert.NoError(t, err) r, err := sslClient.Do(req) @@ -505,7 +505,7 @@ func TestSSLRedirect(t *testing.T) { } func sslRedirect(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:8087?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:8087?hello=world", nil) assert.NoError(t, err) r, err := sslClient.Do(req) @@ -593,7 +593,7 @@ func TestSSLPushPipes(t *testing.T) { } func sslPush(t *testing.T) { - req, err := http.NewRequest("GET", "https://localhost:8894?hello=world", nil) + req, err := http.NewRequest("GET", "https://127.0.0.1:8894?hello=world", nil) assert.NoError(t, err) r, err := sslClient.Do(req) @@ -864,7 +864,7 @@ func TestH2CUpgrade(t *testing.T) { } func h2cUpgrade(t *testing.T) { - req, err := http.NewRequest("PRI", "http://localhost:8083?hello=world", nil) + req, err := http.NewRequest("PRI", "http://127.0.0.1:8083?hello=world", nil) if err != nil { t.Fatal(err) } @@ -955,7 +955,7 @@ func TestH2C(t *testing.T) { } func h2c(t *testing.T) { - req, err := http.NewRequest("PRI", "http://localhost:8083?hello=world", nil) + req, err := http.NewRequest("PRI", "http://127.0.0.1:8083?hello=world", nil) if err != nil { t.Fatal(err) } @@ -1047,7 +1047,7 @@ func TestHttpMiddleware(t *testing.T) { } func middleware(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:18903?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:18903?hello=world", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -1062,7 +1062,7 @@ func middleware(t *testing.T) { err = r.Body.Close() assert.NoError(t, err) - req, err = http.NewRequest("GET", "http://localhost:18903/halt", nil) + req, err = http.NewRequest("GET", "http://127.0.0.1:18903/halt", nil) assert.NoError(t, err) r, err = http.DefaultClient.Do(req) @@ -1127,7 +1127,7 @@ logs: mockLogger.EXPECT().Debug(gomock.Any()).AnyTimes() mockLogger.EXPECT().Debug("worker destructed", "pid", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Debug("worker constructed", "pid", gomock.Any()).MinTimes(1) - mockLogger.EXPECT().Debug("201 GET http://localhost:34999/?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1) + mockLogger.EXPECT().Debug("201 GET http://127.0.0.1:34999/?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Info("WORLD").MinTimes(1) mockLogger.EXPECT().Debug("worker event received", "event", events.EventWorkerLog, "worker state", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Error(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() // placeholder for the workerlogerror @@ -1193,7 +1193,7 @@ logs: } func echoError(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:34999?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:34999?hello=world", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -1278,7 +1278,7 @@ func TestHttpEnvVariables(t *testing.T) { } func envVarsTest(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:12084", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:12084", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -1432,7 +1432,7 @@ func TestHTTPSupervisedPool(t *testing.T) { } func echoHTTP2(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:18888?hello=world", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:18888?hello=world", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -1638,7 +1638,7 @@ func bigEchoHTTP(t *testing.T) { bt := bytes.NewBuffer(buf) - req, err := http.NewRequest("GET", "http://localhost:10085?hello=world", bt) + req, err := http.NewRequest("GET", "http://127.0.0.1:10085?hello=world", bt) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -1723,7 +1723,7 @@ func TestStaticEtagPlugin(t *testing.T) { func serveStaticSampleEtag(t *testing.T) { // OK 200 response - b, r, err := get("http://localhost:21603/sample.txt") + b, r, err := get("http://127.0.0.1:21603/sample.txt") assert.NoError(t, err) assert.Equal(t, "sample\n", b) assert.Equal(t, r.StatusCode, http.StatusOK) @@ -1736,7 +1736,7 @@ func serveStaticSampleEtag(t *testing.T) { Timeout: time.Second * 5, } - parsedURL, _ := url.Parse("http://localhost:21603/sample.txt") + parsedURL, _ := url.Parse("http://127.0.0.1:21603/sample.txt") req := &http.Request{ Method: http.MethodGet, @@ -1828,7 +1828,7 @@ func serveStaticSampleNotAllowedPath(t *testing.T) { parsedURL := &url.URL{ Scheme: "http", User: nil, - Host: "localhost:21603", + Host: "127.0.0.1:21603", Path: "%2e%2e%/tests/", } @@ -1845,7 +1845,7 @@ func serveStaticSampleNotAllowedPath(t *testing.T) { parsedURL = &url.URL{ Scheme: "http", User: nil, - Host: "localhost:21603", + Host: "127.0.0.1:21603", Path: "%2e%2e%5ctests/", } @@ -1862,7 +1862,7 @@ func serveStaticSampleNotAllowedPath(t *testing.T) { parsedURL = &url.URL{ Scheme: "http", User: nil, - Host: "localhost:21603", + Host: "127.0.0.1:21603", Path: "..%2ftests/", } @@ -1879,7 +1879,7 @@ func serveStaticSampleNotAllowedPath(t *testing.T) { parsedURL = &url.URL{ Scheme: "http", User: nil, - Host: "localhost:21603", + Host: "127.0.0.1:21603", Path: "%2e%2e%2ftests/", } @@ -1893,7 +1893,7 @@ func serveStaticSampleNotAllowedPath(t *testing.T) { assert.Equal(t, http.StatusBadRequest, resp.StatusCode) _ = resp.Body.Close() - _, r, err := get("http://localhost:21603/../../../../tests/../static/sample.txt") + _, r, err := get("http://127.0.0.1:21603/../../../../tests/../static/sample.txt") assert.NoError(t, err) assert.Equal(t, 403, r.StatusCode) _ = r.Body.Close() @@ -1971,7 +1971,7 @@ func TestStaticPlugin(t *testing.T) { } func staticHeaders(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:21603/client.php", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:21603/client.php", nil) if err != nil { t.Fatal(err) } @@ -1999,7 +1999,7 @@ func staticHeaders(t *testing.T) { } func staticNotForbid(t *testing.T) { - b, r, err := get("http://localhost:21603/client.php") + b, r, err := get("http://127.0.0.1:21603/client.php") assert.NoError(t, err) assert.Equal(t, all("../../../tests/client.php"), b) assert.Equal(t, all("../../../tests/client.php"), b) @@ -2007,7 +2007,7 @@ func staticNotForbid(t *testing.T) { } func serveStaticSample(t *testing.T) { - b, r, err := get("http://localhost:21603/sample.txt") + b, r, err := get("http://127.0.0.1:21603/sample.txt") assert.NoError(t, err) assert.Equal(t, "sample\n", b) _ = r.Body.Close() @@ -2104,7 +2104,7 @@ func TestStaticFilesDisabled(t *testing.T) { } func staticFilesDisabled(t *testing.T) { - b, r, err := get("http://localhost:45877/client.php?hello=world") + b, r, err := get("http://127.0.0.1:45877/client.php?hello=world") if err != nil { t.Fatal(err) } @@ -2126,9 +2126,9 @@ func TestStaticFilesForbid(t *testing.T) { mockLogger.EXPECT().Debug("worker destructed", "pid", gomock.Any()).AnyTimes() mockLogger.EXPECT().Debug("worker constructed", "pid", gomock.Any()).AnyTimes() - mockLogger.EXPECT().Debug("201 GET http://localhost:34653/http?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1) - mockLogger.EXPECT().Debug("201 GET http://localhost:34653/client.XXX?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1) - mockLogger.EXPECT().Debug("201 GET http://localhost:34653/client.php?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1) + mockLogger.EXPECT().Debug("201 GET http://127.0.0.1:34653/http?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1) + mockLogger.EXPECT().Debug("201 GET http://127.0.0.1:34653/client.XXX?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1) + mockLogger.EXPECT().Debug("201 GET http://127.0.0.1:34653/client.php?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Error("file open error", "error", gomock.Any()).AnyTimes() mockLogger.EXPECT().Debug("no such file or directory", "error", gomock.Any()).AnyTimes() mockLogger.EXPECT().Debug("possible path to dir provided").AnyTimes() @@ -2198,19 +2198,19 @@ func TestStaticFilesForbid(t *testing.T) { } func staticTestFilesDir(t *testing.T) { - b, r, err := get("http://localhost:34653/http?hello=world") + b, r, err := get("http://127.0.0.1:34653/http?hello=world") assert.NoError(t, err) assert.Equal(t, "WORLD", b) _ = r.Body.Close() } func staticNotFound(t *testing.T) { - b, _, _ := get("http://localhost:34653/client.XXX?hello=world") //nolint:bodyclose + b, _, _ := get("http://127.0.0.1:34653/client.XXX?hello=world") //nolint:bodyclose assert.Equal(t, "WORLD", b) } func staticFilesForbid(t *testing.T) { - b, r, err := get("http://localhost:34653/client.php?hello=world") + b, r, err := get("http://127.0.0.1:34653/client.php?hello=world") if err != nil { t.Fatal(err) } @@ -2288,7 +2288,7 @@ func TestHTTPIssue659(t *testing.T) { } func echoIssue659(t *testing.T) { - req, err := http.NewRequest(http.MethodGet, "http://localhost:32552", nil) + req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:32552", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) diff --git a/tests/plugins/http/uploads_test.go b/tests/plugins/http/uploads_test.go index d02f9eee..54f2bead 100644 --- a/tests/plugins/http/uploads_test.go +++ b/tests/plugins/http/uploads_test.go @@ -85,7 +85,7 @@ func TestHandler_Upload_File(t *testing.T) { t.Errorf("error closing the file: error %v", err) } - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, &mb) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) @@ -168,7 +168,7 @@ func TestHandler_Upload_NestedFile(t *testing.T) { t.Errorf("error closing the file: error %v", err) } - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, &mb) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) @@ -251,7 +251,7 @@ func TestHandler_Upload_File_NoTmpDir(t *testing.T) { t.Errorf("error closing the file: error %v", err) } - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, &mb) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) @@ -334,7 +334,7 @@ func TestHandler_Upload_File_Forbids(t *testing.T) { t.Errorf("error closing the file: error %v", err) } - req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, &mb) + req, err := http.NewRequest("POST", "http://127.0.0.1"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) diff --git a/tests/plugins/jobs/amqp/.rr-amqp-declare.yaml b/tests/plugins/jobs/amqp/.rr-amqp-declare.yaml index ed0345d6..32883ce2 100644 --- a/tests/plugins/jobs/amqp/.rr-amqp-declare.yaml +++ b/tests/plugins/jobs/amqp/.rr-amqp-declare.yaml @@ -7,7 +7,7 @@ server: relay_timeout: "20s" amqp: - addr: amqp://guest:guest@localhost:5672/ + addr: amqp://guest:[email protected]:5672/ logs: level: debug diff --git a/tests/plugins/jobs/amqp/.rr-amqp-init.yaml b/tests/plugins/jobs/amqp/.rr-amqp-init.yaml index 5c585372..c06b5a79 100644 --- a/tests/plugins/jobs/amqp/.rr-amqp-init.yaml +++ b/tests/plugins/jobs/amqp/.rr-amqp-init.yaml @@ -7,7 +7,7 @@ server: relay_timeout: "20s" amqp: - addr: amqp://guest:guest@localhost:5672/ + addr: amqp://guest:[email protected]:5672/ logs: level: debug diff --git a/tests/plugins/jobs/beanstalk/.rr-beanstalk-declare.yaml b/tests/plugins/jobs/beanstalk/.rr-beanstalk-declare.yaml index 85f92bac..022bf2f4 100644 --- a/tests/plugins/jobs/beanstalk/.rr-beanstalk-declare.yaml +++ b/tests/plugins/jobs/beanstalk/.rr-beanstalk-declare.yaml @@ -8,7 +8,7 @@ server: beanstalk: # beanstalk address - addr: tcp://localhost:11300 + addr: tcp://127.0.0.1:11300 # connect timeout timeout: 10s diff --git a/tests/plugins/jobs/beanstalk/.rr-beanstalk-init.yaml b/tests/plugins/jobs/beanstalk/.rr-beanstalk-init.yaml index 66cfd52e..8ded8cf1 100644 --- a/tests/plugins/jobs/beanstalk/.rr-beanstalk-init.yaml +++ b/tests/plugins/jobs/beanstalk/.rr-beanstalk-init.yaml @@ -7,7 +7,7 @@ server: relay_timeout: "20s" beanstalk: - addr: tcp://localhost:11300 + addr: tcp://127.0.0.1:11300 timeout: 10s logs: diff --git a/tests/plugins/jobs/configs/.rr-jobs-init.yaml b/tests/plugins/jobs/configs/.rr-jobs-init.yaml index 550e55cc..bf9f60cc 100644 --- a/tests/plugins/jobs/configs/.rr-jobs-init.yaml +++ b/tests/plugins/jobs/configs/.rr-jobs-init.yaml @@ -7,13 +7,13 @@ server: relay_timeout: "20s" amqp: - addr: amqp://guest:guest@localhost:5672/ + addr: amqp://guest:[email protected]:5672/ # beanstalk configuration # beanstalk: # beanstalk address - addr: tcp://localhost:11300 + addr: tcp://127.0.0.1:11300 # connect timeout timeout: 10s @@ -23,7 +23,7 @@ sqs: key: api-key secret: api-secret region: us-west-1 - endpoint: http://localhost:9324 + endpoint: http://127.0.0.1:9324 logs: level: info diff --git a/tests/plugins/jobs/durability/.rr-amqp-durability-redial.yaml b/tests/plugins/jobs/durability/.rr-amqp-durability-redial.yaml index a66e1979..861f7ec4 100644 --- a/tests/plugins/jobs/durability/.rr-amqp-durability-redial.yaml +++ b/tests/plugins/jobs/durability/.rr-amqp-durability-redial.yaml @@ -7,7 +7,7 @@ server: relay_timeout: "20s" amqp: - addr: amqp://guest:guest@localhost:23679/ + addr: amqp://guest:[email protected]:23679/ logs: level: debug diff --git a/tests/plugins/jobs/durability/.rr-beanstalk-durability-redial.yaml b/tests/plugins/jobs/durability/.rr-beanstalk-durability-redial.yaml index 22d8f3b0..57d8ad2d 100644 --- a/tests/plugins/jobs/durability/.rr-beanstalk-durability-redial.yaml +++ b/tests/plugins/jobs/durability/.rr-beanstalk-durability-redial.yaml @@ -7,7 +7,7 @@ server: relay_timeout: "20s" beanstalk: - addr: tcp://localhost:11400 + addr: tcp://127.0.0.1:11400 timeout: 10s logs: diff --git a/tests/plugins/jobs/durability/.rr-sqs-durability-redial.yaml b/tests/plugins/jobs/durability/.rr-sqs-durability-redial.yaml index d7d93fe6..8f1a1d5d 100644 --- a/tests/plugins/jobs/durability/.rr-sqs-durability-redial.yaml +++ b/tests/plugins/jobs/durability/.rr-sqs-durability-redial.yaml @@ -10,7 +10,7 @@ sqs: key: api-key secret: api-secret region: us-west-1 - endpoint: http://localhost:19324 + endpoint: http://127.0.0.1:19324 logs: level: debug diff --git a/tests/plugins/jobs/helpers.go b/tests/plugins/jobs/helpers.go index 0d7d6ac6..831c732c 100644 --- a/tests/plugins/jobs/helpers.go +++ b/tests/plugins/jobs/helpers.go @@ -154,7 +154,7 @@ func enableProxy(name string, t *testing.T) { buf := new(bytes.Buffer) buf.WriteString(`{"enabled":true}`) - resp, err := http.Post("http://localhost:8474/proxies/"+name, "application/json", buf) //nolint:noctx + resp, err := http.Post("http://127.0.0.1:8474/proxies/"+name, "application/json", buf) //nolint:noctx require.NoError(t, err) require.Equal(t, 200, resp.StatusCode) if resp.Body != nil { @@ -166,7 +166,7 @@ func disableProxy(name string, t *testing.T) { buf := new(bytes.Buffer) buf.WriteString(`{"enabled":false}`) - resp, err := http.Post("http://localhost:8474/proxies/"+name, "application/json", buf) //nolint:noctx + resp, err := http.Post("http://127.0.0.1:8474/proxies/"+name, "application/json", buf) //nolint:noctx require.NoError(t, err) require.Equal(t, 200, resp.StatusCode) if resp.Body != nil { @@ -177,7 +177,7 @@ func disableProxy(name string, t *testing.T) { func deleteProxy(name string, t *testing.T) { client := &http.Client{} - req, err := http.NewRequest(http.MethodDelete, "http://localhost:8474/proxies/"+name, nil) //nolint:noctx + req, err := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8474/proxies/"+name, nil) //nolint:noctx require.NoError(t, err) resp, err := client.Do(req) diff --git a/tests/plugins/jobs/jobs_with_toxics_test.go b/tests/plugins/jobs/jobs_with_toxics_test.go index 7e2bd8be..71986db3 100644 --- a/tests/plugins/jobs/jobs_with_toxics_test.go +++ b/tests/plugins/jobs/jobs_with_toxics_test.go @@ -27,9 +27,9 @@ import ( ) func TestDurabilityAMQP(t *testing.T) { - client := toxiproxy.NewClient("localhost:8474") + client := toxiproxy.NewClient("127.0.0.1:8474") - _, err := client.CreateProxy("redial", "localhost:23679", "localhost:5672") + _, err := client.CreateProxy("redial", "127.0.0.1:23679", "127.0.0.1:5672") require.NoError(t, err) defer deleteProxy("redial", t) @@ -150,9 +150,9 @@ func TestDurabilityAMQP(t *testing.T) { } func TestDurabilitySQS(t *testing.T) { - client := toxiproxy.NewClient("localhost:8474") + client := toxiproxy.NewClient("127.0.0.1:8474") - _, err := client.CreateProxy("redial", "localhost:19324", "localhost:9324") + _, err := client.CreateProxy("redial", "127.0.0.1:19324", "127.0.0.1:9324") require.NoError(t, err) defer deleteProxy("redial", t) @@ -273,9 +273,9 @@ func TestDurabilitySQS(t *testing.T) { } func TestDurabilityBeanstalk(t *testing.T) { - client := toxiproxy.NewClient("localhost:8474") + client := toxiproxy.NewClient("127.0.0.1:8474") - _, err := client.CreateProxy("redial", "localhost:11400", "localhost:11300") + _, err := client.CreateProxy("redial", "127.0.0.1:11400", "127.0.0.1:11300") require.NoError(t, err) defer deleteProxy("redial", t) diff --git a/tests/plugins/jobs/sqs/.rr-sqs-declare.yaml b/tests/plugins/jobs/sqs/.rr-sqs-declare.yaml index d75265ee..c4eb9cf9 100644 --- a/tests/plugins/jobs/sqs/.rr-sqs-declare.yaml +++ b/tests/plugins/jobs/sqs/.rr-sqs-declare.yaml @@ -12,7 +12,7 @@ sqs: key: api-key secret: api-secret region: us-west-1 - endpoint: http://localhost:9324 + endpoint: http://127.0.0.1:9324 logs: level: debug diff --git a/tests/plugins/jobs/sqs/.rr-sqs-init.yaml b/tests/plugins/jobs/sqs/.rr-sqs-init.yaml index 8c62bbdb..239f9954 100644 --- a/tests/plugins/jobs/sqs/.rr-sqs-init.yaml +++ b/tests/plugins/jobs/sqs/.rr-sqs-init.yaml @@ -10,7 +10,7 @@ sqs: key: api-key secret: api-secret region: us-west-1 - endpoint: http://localhost:9324 + endpoint: http://127.0.0.1:9324 logs: level: debug diff --git a/tests/plugins/kv/configs/.rr-kv-init.yaml b/tests/plugins/kv/configs/.rr-kv-init.yaml index 34e22a4e..a13b591c 100644 --- a/tests/plugins/kv/configs/.rr-kv-init.yaml +++ b/tests/plugins/kv/configs/.rr-kv-init.yaml @@ -24,7 +24,7 @@ kv: memcached: driver: memcached - addr: [ "localhost:11211" ] + addr: [ "127.0.0.1:11211" ] # redis: # driver: redis diff --git a/tests/plugins/kv/configs/.rr-memcached.yaml b/tests/plugins/kv/configs/.rr-memcached.yaml index 68443bc4..da5d59c6 100644 --- a/tests/plugins/kv/configs/.rr-memcached.yaml +++ b/tests/plugins/kv/configs/.rr-memcached.yaml @@ -9,4 +9,4 @@ kv: memcached-rr: driver: memcached addr: - - "localhost:11211" + - "127.0.0.1:11211" diff --git a/tests/plugins/kv/configs/.rr-redis-global.yaml b/tests/plugins/kv/configs/.rr-redis-global.yaml index d2e8aefe..a4979879 100644 --- a/tests/plugins/kv/configs/.rr-redis-global.yaml +++ b/tests/plugins/kv/configs/.rr-redis-global.yaml @@ -7,7 +7,7 @@ logs: redis-rr: addrs: - - 'localhost:6379' + - '127.0.0.1:6379' kv: redis-rr: diff --git a/tests/plugins/kv/configs/.rr-redis.yaml b/tests/plugins/kv/configs/.rr-redis.yaml index 0a7396ca..522e365a 100644 --- a/tests/plugins/kv/configs/.rr-redis.yaml +++ b/tests/plugins/kv/configs/.rr-redis.yaml @@ -9,4 +9,4 @@ kv: redis-rr: driver: redis addrs: - - 'localhost:6379' + - '127.0.0.1:6379' diff --git a/tests/plugins/logger/logger_test.go b/tests/plugins/logger/logger_test.go index 9e3fa4da..ec4a748d 100644 --- a/tests/plugins/logger/logger_test.go +++ b/tests/plugins/logger/logger_test.go @@ -347,7 +347,7 @@ func TestFileLogger(t *testing.T) { } func httpEcho(t *testing.T) { - req, err := http.NewRequest(http.MethodGet, "http://localhost:54224?hello=world", nil) + req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:54224?hello=world", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) diff --git a/tests/plugins/metrics/configs/.rr-http-metrics.yaml b/tests/plugins/metrics/configs/.rr-http-metrics.yaml index 95f131c0..3e92a88c 100644 --- a/tests/plugins/metrics/configs/.rr-http-metrics.yaml +++ b/tests/plugins/metrics/configs/.rr-http-metrics.yaml @@ -13,7 +13,7 @@ http: num_workers: 1 metrics: - address: localhost:2112 + address: 127.0.0.1:2112 logs: mode: development diff --git a/tests/plugins/metrics/configs/.rr-test.yaml b/tests/plugins/metrics/configs/.rr-test.yaml index 4890076f..b5c4e64f 100644 --- a/tests/plugins/metrics/configs/.rr-test.yaml +++ b/tests/plugins/metrics/configs/.rr-test.yaml @@ -3,7 +3,7 @@ rpc: metrics: # prometheus client address (path /metrics added automatically) - address: localhost:2112 + address: 127.0.0.1:2112 collect: app_metric: type: histogram @@ -15,4 +15,4 @@ metrics: help: "Custom application counter." logs: mode: development - level: error
\ No newline at end of file + level: error diff --git a/tests/plugins/metrics/metrics_test.go b/tests/plugins/metrics/metrics_test.go index 3d900fcc..c4ea9f2c 100644 --- a/tests/plugins/metrics/metrics_test.go +++ b/tests/plugins/metrics/metrics_test.go @@ -27,7 +27,7 @@ import ( const dialAddr = "127.0.0.1:6001" const dialNetwork = "tcp" -const getAddr = "http://localhost:2112/metrics" +const getAddr = "http://127.0.0.1:2112/metrics" // get request and return body func get() (string, error) { @@ -130,7 +130,7 @@ func TestMetricsIssue571(t *testing.T) { mockLogger.EXPECT().Debug("worker destructed", "pid", gomock.Any()).AnyTimes() mockLogger.EXPECT().Debug("worker constructed", "pid", gomock.Any()).AnyTimes() mockLogger.EXPECT().Debug("Started RPC service", "address", "tcp://127.0.0.1:6001", "services", []string{"metrics"}).MinTimes(1) - mockLogger.EXPECT().Debug("200 GET http://localhost:56444/", "remote", gomock.Any(), "elapsed", gomock.Any()).MinTimes(1) + mockLogger.EXPECT().Debug("200 GET http://127.0.0.1:56444/", "remote", gomock.Any(), "elapsed", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Info("declaring new metric", "name", "test", "type", gomock.Any(), "namespace", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Info("metric successfully added", "name", "test", "type", gomock.Any(), "namespace", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Info("metric successfully added", "name", "test", "labels", []string{}, "value", gomock.Any()).MinTimes(1) @@ -209,7 +209,7 @@ func TestMetricsIssue571(t *testing.T) { // get request and return body func issue571Http() (string, error) { - r, err := http.Get("http://localhost:56444") + r, err := http.Get("http://127.0.0.1:56444") if err != nil { return "", err } @@ -229,7 +229,7 @@ func issue571Http() (string, error) { // get request and return body func issue571Metrics() (string, error) { - r, err := http.Get("http://localhost:23557") + r, err := http.Get("http://127.0.0.1:23557") if err != nil { return "", err } @@ -989,7 +989,7 @@ func TestHTTPMetrics(t *testing.T) { mockLogger.EXPECT().Debug("worker destructed", "pid", gomock.Any()).AnyTimes() mockLogger.EXPECT().Debug("worker constructed", "pid", gomock.Any()).AnyTimes() - mockLogger.EXPECT().Debug("200 GET http://localhost:13223/", "remote", gomock.Any(), "elapsed", gomock.Any()).MinTimes(1) + mockLogger.EXPECT().Debug("200 GET http://127.0.0.1:13223/", "remote", gomock.Any(), "elapsed", gomock.Any()).MinTimes(1) err = cont.RegisterAll( cfg, @@ -1056,7 +1056,7 @@ func TestHTTPMetrics(t *testing.T) { } func echoHTTP(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost:13223", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:13223", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) diff --git a/tests/plugins/redis/redis_plugin_test.go b/tests/plugins/redis/redis_plugin_test.go index 96a191a1..1b84e339 100644 --- a/tests/plugins/redis/redis_plugin_test.go +++ b/tests/plugins/redis/redis_plugin_test.go @@ -21,7 +21,7 @@ func redisConfig(port string) string { cfg := ` redis: addrs: - - 'localhost:%s' + - '127.0.0.1:%s' master_name: '' username: '' password: '' diff --git a/tests/plugins/server/configs/.rr-tcp.yaml b/tests/plugins/server/configs/.rr-tcp.yaml index 4582482f..6b9c9ddb 100644 --- a/tests/plugins/server/configs/.rr-tcp.yaml +++ b/tests/plugins/server/configs/.rr-tcp.yaml @@ -5,7 +5,7 @@ server: env: - RR_CONFIG: "/some/place/on/the/C134" - RR_CONFIG2: "C138" - relay: "tcp://localhost:9999" + relay: "tcp://127.0.0.1:9999" relay_timeout: "20s" logs: mode: development diff --git a/tests/plugins/server/tcp.php b/tests/plugins/server/tcp.php index 873f25b2..acc1e1a5 100644 --- a/tests/plugins/server/tcp.php +++ b/tests/plugins/server/tcp.php @@ -8,7 +8,7 @@ use Spiral\RoadRunner; require dirname(__DIR__) . "/../vendor/autoload.php"; -$relay = new Goridge\SocketRelay("localhost", 9999); +$relay = new Goridge\SocketRelay("127.0.0.1", 9999); $rr = new RoadRunner\Worker($relay); while ($in = $rr->waitPayload()) { diff --git a/tests/plugins/status/plugin_test.go b/tests/plugins/status/plugin_test.go index 663f4ee3..227cfd46 100644 --- a/tests/plugins/status/plugin_test.go +++ b/tests/plugins/status/plugin_test.go @@ -345,7 +345,7 @@ func TestReadinessRPCWorkerNotReady(t *testing.T) { func doHTTPReq(t *testing.T) { go func() { - req, err := http.NewRequest("GET", "http://localhost:11933", nil) + req, err := http.NewRequest("GET", "http://127.0.0.1:11933", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) diff --git a/tests/plugins/websockets/configs/.rr-websockets-allow.yaml b/tests/plugins/websockets/configs/.rr-websockets-allow.yaml index e6c43857..900094a4 100644 --- a/tests/plugins/websockets/configs/.rr-websockets-allow.yaml +++ b/tests/plugins/websockets/configs/.rr-websockets-allow.yaml @@ -21,7 +21,7 @@ http: redis: addrs: - - "localhost:6379" + - "127.0.0.1:6379" broadcast: test: diff --git a/tests/plugins/websockets/configs/.rr-websockets-allow2.yaml b/tests/plugins/websockets/configs/.rr-websockets-allow2.yaml index d537a80b..43f4b2ec 100644 --- a/tests/plugins/websockets/configs/.rr-websockets-allow2.yaml +++ b/tests/plugins/websockets/configs/.rr-websockets-allow2.yaml @@ -21,13 +21,13 @@ http: redis: addrs: - - "localhost:6379" + - "127.0.0.1:6379" broadcast: test: driver: redis addrs: - - "localhost:6379" + - "127.0.0.1:6379" websockets: broker: test diff --git a/tests/plugins/websockets/configs/.rr-websockets-deny2.yaml b/tests/plugins/websockets/configs/.rr-websockets-deny2.yaml index 4deea30a..e0bdf993 100644 --- a/tests/plugins/websockets/configs/.rr-websockets-deny2.yaml +++ b/tests/plugins/websockets/configs/.rr-websockets-deny2.yaml @@ -23,7 +23,7 @@ broadcast: test: driver: redis addrs: - - "localhost:6379" + - "127.0.0.1:6379" websockets: broker: test diff --git a/tests/plugins/websockets/configs/.rr-websockets-redis.yaml b/tests/plugins/websockets/configs/.rr-websockets-redis.yaml index 3557f5f1..e3d5f0b8 100644 --- a/tests/plugins/websockets/configs/.rr-websockets-redis.yaml +++ b/tests/plugins/websockets/configs/.rr-websockets-redis.yaml @@ -21,7 +21,7 @@ http: redis: addrs: - - "localhost:6379" + - "127.0.0.1:6379" broadcast: test: diff --git a/tests/plugins/websockets/websocket_plugin_test.go b/tests/plugins/websockets/websocket_plugin_test.go index 53b6a572..bfdc980b 100644 --- a/tests/plugins/websockets/websocket_plugin_test.go +++ b/tests/plugins/websockets/websocket_plugin_test.go @@ -443,7 +443,7 @@ func RPCWsMemoryStop(port string) func(t *testing.T) { HandshakeTimeout: time.Second * 20, } - connURL := url.URL{Scheme: "ws", Host: "localhost:" + port, Path: "/ws"} + connURL := url.URL{Scheme: "ws", Host: "127.0.0.1:" + port, Path: "/ws"} c, resp, err := da.Dial(connURL.String(), nil) assert.NotNil(t, resp) @@ -613,7 +613,7 @@ func wsInit(t *testing.T) { HandshakeTimeout: time.Second * 20, } - connURL := url.URL{Scheme: "ws", Host: "localhost:11111", Path: "/ws"} + connURL := url.URL{Scheme: "ws", Host: "127.0.0.1:11111", Path: "/ws"} c, resp, err := da.Dial(connURL.String(), nil) assert.NoError(t, err) @@ -648,7 +648,7 @@ func RPCWsPubAsync(port string) func(t *testing.T) { HandshakeTimeout: time.Second * 20, } - connURL := url.URL{Scheme: "ws", Host: "localhost:" + port, Path: "/ws"} + connURL := url.URL{Scheme: "ws", Host: "127.0.0.1:" + port, Path: "/ws"} c, resp, err := da.Dial(connURL.String(), nil) assert.NoError(t, err) @@ -725,7 +725,7 @@ func RPCWsPub(port string) func(t *testing.T) { HandshakeTimeout: time.Second * 20, } - connURL := url.URL{Scheme: "ws", Host: "localhost:" + port, Path: "/ws"} + connURL := url.URL{Scheme: "ws", Host: "127.0.0.1:" + port, Path: "/ws"} c, resp, err := da.Dial(connURL.String(), nil) assert.NoError(t, err) @@ -802,7 +802,7 @@ func RPCWsDeny(port string) func(t *testing.T) { HandshakeTimeout: time.Second * 20, } - connURL := url.URL{Scheme: "ws", Host: "localhost:" + port, Path: "/ws"} + connURL := url.URL{Scheme: "ws", Host: "127.0.0.1:" + port, Path: "/ws"} c, resp, err := da.Dial(connURL.String(), nil) assert.NoError(t, err) diff --git a/tests/slow-client.php b/tests/slow-client.php index 7737f0b1..c21b45d2 100644 --- a/tests/slow-client.php +++ b/tests/slow-client.php @@ -17,7 +17,7 @@ switch ($goridge) { break; case "tcp": - $relay = new Goridge\SocketRelay("localhost", 9007); + $relay = new Goridge\SocketRelay("127.0.0.1", 9007); break; case "unix": diff --git a/tests/slow-destroy.php b/tests/slow-destroy.php index 900bb68a..2edbc0db 100644 --- a/tests/slow-destroy.php +++ b/tests/slow-destroy.php @@ -17,7 +17,7 @@ switch ($goridge) { break; case "tcp": - $relay = new Goridge\SocketRelay("localhost", 9007); + $relay = new Goridge\SocketRelay("127.0.0.1", 9007); break; case "unix": diff --git a/utils/to_ptr.go b/utils/to_ptr.go new file mode 100644 index 00000000..7c93ef46 --- /dev/null +++ b/utils/to_ptr.go @@ -0,0 +1,467 @@ +package utils + +import "time" + +// Bool returns a pointer value for the bool value passed in. +func Bool(v bool) *bool { + return &v +} + +// BoolSlice returns a slice of bool pointers from the values +// passed in. +func BoolSlice(vs []bool) []*bool { + ps := make([]*bool, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// BoolMap returns a map of bool pointers from the values +// passed in. +func BoolMap(vs map[string]bool) map[string]*bool { + ps := make(map[string]*bool, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Byte returns a pointer value for the byte value passed in. +func Byte(v byte) *byte { + return &v +} + +// ByteSlice returns a slice of byte pointers from the values +// passed in. +func ByteSlice(vs []byte) []*byte { + ps := make([]*byte, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// ByteMap returns a map of byte pointers from the values +// passed in. +func ByteMap(vs map[string]byte) map[string]*byte { + ps := make(map[string]*byte, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// String returns a pointer value for the string value passed in. +func String(v string) *string { + return &v +} + +// StringSlice returns a slice of string pointers from the values +// passed in. +func StringSlice(vs []string) []*string { + ps := make([]*string, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// StringMap returns a map of string pointers from the values +// passed in. +func StringMap(vs map[string]string) map[string]*string { + ps := make(map[string]*string, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Int returns a pointer value for the int value passed in. +func Int(v int) *int { + return &v +} + +// IntSlice returns a slice of int pointers from the values +// passed in. +func IntSlice(vs []int) []*int { + ps := make([]*int, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// IntMap returns a map of int pointers from the values +// passed in. +func IntMap(vs map[string]int) map[string]*int { + ps := make(map[string]*int, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Int8 returns a pointer value for the int8 value passed in. +func Int8(v int8) *int8 { + return &v +} + +// Int8Slice returns a slice of int8 pointers from the values +// passed in. +func Int8Slice(vs []int8) []*int8 { + ps := make([]*int8, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Int8Map returns a map of int8 pointers from the values +// passed in. +func Int8Map(vs map[string]int8) map[string]*int8 { + ps := make(map[string]*int8, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Int16 returns a pointer value for the int16 value passed in. +func Int16(v int16) *int16 { + return &v +} + +// Int16Slice returns a slice of int16 pointers from the values +// passed in. +func Int16Slice(vs []int16) []*int16 { + ps := make([]*int16, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Int16Map returns a map of int16 pointers from the values +// passed in. +func Int16Map(vs map[string]int16) map[string]*int16 { + ps := make(map[string]*int16, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Int32 returns a pointer value for the int32 value passed in. +func Int32(v int32) *int32 { + return &v +} + +// Int32Slice returns a slice of int32 pointers from the values +// passed in. +func Int32Slice(vs []int32) []*int32 { + ps := make([]*int32, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Int32Map returns a map of int32 pointers from the values +// passed in. +func Int32Map(vs map[string]int32) map[string]*int32 { + ps := make(map[string]*int32, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Int64 returns a pointer value for the int64 value passed in. +func Int64(v int64) *int64 { + return &v +} + +// Int64Slice returns a slice of int64 pointers from the values +// passed in. +func Int64Slice(vs []int64) []*int64 { + ps := make([]*int64, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Int64Map returns a map of int64 pointers from the values +// passed in. +func Int64Map(vs map[string]int64) map[string]*int64 { + ps := make(map[string]*int64, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Uint returns a pointer value for the uint value passed in. +func Uint(v uint) *uint { + return &v +} + +// UintSlice returns a slice of uint pointers from the values +// passed in. +func UintSlice(vs []uint) []*uint { + ps := make([]*uint, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// UintMap returns a map of uint pointers from the values +// passed in. +func UintMap(vs map[string]uint) map[string]*uint { + ps := make(map[string]*uint, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Uint8 returns a pointer value for the uint8 value passed in. +func Uint8(v uint8) *uint8 { + return &v +} + +// Uint8Slice returns a slice of uint8 pointers from the values +// passed in. +func Uint8Slice(vs []uint8) []*uint8 { + ps := make([]*uint8, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Uint8Map returns a map of uint8 pointers from the values +// passed in. +func Uint8Map(vs map[string]uint8) map[string]*uint8 { + ps := make(map[string]*uint8, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Uint16 returns a pointer value for the uint16 value passed in. +func Uint16(v uint16) *uint16 { + return &v +} + +// Uint16Slice returns a slice of uint16 pointers from the values +// passed in. +func Uint16Slice(vs []uint16) []*uint16 { + ps := make([]*uint16, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Uint16Map returns a map of uint16 pointers from the values +// passed in. +func Uint16Map(vs map[string]uint16) map[string]*uint16 { + ps := make(map[string]*uint16, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Uint32 returns a pointer value for the uint32 value passed in. +func Uint32(v uint32) *uint32 { + return &v +} + +// Uint32Slice returns a slice of uint32 pointers from the values +// passed in. +func Uint32Slice(vs []uint32) []*uint32 { + ps := make([]*uint32, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Uint32Map returns a map of uint32 pointers from the values +// passed in. +func Uint32Map(vs map[string]uint32) map[string]*uint32 { + ps := make(map[string]*uint32, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Uint64 returns a pointer value for the uint64 value passed in. +func Uint64(v uint64) *uint64 { + return &v +} + +// Uint64Slice returns a slice of uint64 pointers from the values +// passed in. +func Uint64Slice(vs []uint64) []*uint64 { + ps := make([]*uint64, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Uint64Map returns a map of uint64 pointers from the values +// passed in. +func Uint64Map(vs map[string]uint64) map[string]*uint64 { + ps := make(map[string]*uint64, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Float32 returns a pointer value for the float32 value passed in. +func Float32(v float32) *float32 { + return &v +} + +// Float32Slice returns a slice of float32 pointers from the values +// passed in. +func Float32Slice(vs []float32) []*float32 { + ps := make([]*float32, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Float32Map returns a map of float32 pointers from the values +// passed in. +func Float32Map(vs map[string]float32) map[string]*float32 { + ps := make(map[string]*float32, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Float64 returns a pointer value for the float64 value passed in. +func Float64(v float64) *float64 { + return &v +} + +// Float64Slice returns a slice of float64 pointers from the values +// passed in. +func Float64Slice(vs []float64) []*float64 { + ps := make([]*float64, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// Float64Map returns a map of float64 pointers from the values +// passed in. +func Float64Map(vs map[string]float64) map[string]*float64 { + ps := make(map[string]*float64, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} + +// Time returns a pointer value for the time.Time value passed in. +func Time(v time.Time) *time.Time { + return &v +} + +// TimeSlice returns a slice of time.Time pointers from the values +// passed in. +func TimeSlice(vs []time.Time) []*time.Time { + ps := make([]*time.Time, len(vs)) + for i, v := range vs { + vv := v + ps[i] = &vv + } + + return ps +} + +// TimeMap returns a map of time.Time pointers from the values +// passed in. +func TimeMap(vs map[string]time.Time) map[string]*time.Time { + ps := make(map[string]*time.Time, len(vs)) + for k, v := range vs { + vv := v + ps[k] = &vv + } + + return ps +} |