2
0
mirror of https://github.com/stefan01/transocks.git synced 2025-02-22 03:30:45 +07:00

Replaced "cybozu-go/cmd" to "cybozu-go/cmd"

This commit is contained in:
ayatk 2018-11-07 11:52:08 +09:00 committed by ymmt
parent e3b3eb6602
commit 95ef9ecc98
3 changed files with 18 additions and 18 deletions

View File

@ -7,15 +7,15 @@ import (
"net/url"
"github.com/BurntSushi/toml"
"github.com/cybozu-go/cmd"
"github.com/cybozu-go/log"
"github.com/cybozu-go/transocks"
"github.com/cybozu-go/well"
)
type tomlConfig struct {
Listen string `toml:"listen"`
ProxyURL string `toml:"proxy_url"`
Log cmd.LogConfig `toml:"log"`
Listen string `toml:"listen"`
ProxyURL string `toml:"proxy_url"`
Log well.LogConfig `toml:"log"`
}
const (
@ -65,8 +65,8 @@ func serve(lns []net.Listener, c *transocks.Config) {
for _, ln := range lns {
s.Serve(ln)
}
err = cmd.Wait()
if err != nil && !cmd.IsSignaled(err) {
err = well.Wait()
if err != nil && !well.IsSignaled(err) {
log.ErrorExit(err)
}
}
@ -79,7 +79,7 @@ func main() {
log.ErrorExit(err)
}
g := &cmd.Graceful{
g := &well.Graceful{
Listen: func() ([]net.Listener, error) {
return transocks.Listeners(c)
},
@ -89,8 +89,8 @@ func main() {
}
g.Run()
err = cmd.Wait()
if err != nil && !cmd.IsSignaled(err) {
err = well.Wait()
if err != nil && !well.IsSignaled(err) {
log.ErrorExit(err)
}
}

View File

@ -7,8 +7,8 @@ import (
"net/url"
"time"
"github.com/cybozu-go/cmd"
"github.com/cybozu-go/log"
"github.com/cybozu-go/well"
)
const (
@ -58,9 +58,9 @@ type Config struct {
// If nil, the default logger is used.
Logger *log.Logger
// Env can be used to specify a cmd.Environment on which the server runs.
// Env can be used to specify a well.Environment on which the server runs.
// If nil, the server will run on the global environment.
Env *cmd.Environment
Env *well.Environment
}
// NewConfig creates and initializes a new Config.

View File

@ -7,9 +7,9 @@ import (
"sync"
"time"
"github.com/cybozu-go/cmd"
"github.com/cybozu-go/log"
"github.com/cybozu-go/netutil"
"github.com/cybozu-go/well"
"golang.org/x/net/proxy"
)
@ -29,7 +29,7 @@ func Listeners(c *Config) ([]net.Listener, error) {
// Server provides transparent proxy server functions.
type Server struct {
cmd.Server
well.Server
mode Mode
logger *log.Logger
dialer proxy.Dialer
@ -60,7 +60,7 @@ func NewServer(c *Config) (*Server, error) {
}
s := &Server{
Server: cmd.Server{
Server: well.Server{
ShutdownTimeout: c.ShutdownTimeout,
Env: c.Env,
},
@ -86,7 +86,7 @@ func (s *Server) handleConnection(ctx context.Context, conn net.Conn) {
return
}
fields := cmd.FieldsFromContext(ctx)
fields := well.FieldsFromContext(ctx)
fields[log.FnType] = "access"
fields["client_addr"] = conn.RemoteAddr().String()
@ -117,7 +117,7 @@ func (s *Server) handleConnection(ctx context.Context, conn net.Conn) {
// do proxy
st := time.Now()
env := cmd.NewEnvironment(ctx)
env := well.NewEnvironment(ctx)
env.Go(func(ctx context.Context) error {
buf := s.pool.Get().([]byte)
_, err := io.CopyBuffer(destConn, tc, buf)
@ -141,7 +141,7 @@ func (s *Server) handleConnection(ctx context.Context, conn net.Conn) {
env.Stop()
err = env.Wait()
fields = cmd.FieldsFromContext(ctx)
fields = well.FieldsFromContext(ctx)
fields["elapsed"] = time.Since(st).Seconds()
if err != nil {
fields[log.FnError] = err.Error()