Refactor log
This commit is contained in:
@@ -18,7 +18,7 @@ type Block struct {
|
||||
myOutboundAdapter
|
||||
}
|
||||
|
||||
func NewBlock(logger log.Logger, tag string) *Block {
|
||||
func NewBlock(logger log.ContextLogger, tag string) *Block {
|
||||
return &Block{
|
||||
myOutboundAdapter{
|
||||
protocol: C.TypeBlock,
|
||||
@@ -30,23 +30,23 @@ func NewBlock(logger log.Logger, tag string) *Block {
|
||||
}
|
||||
|
||||
func (h *Block) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
h.logger.WithContext(ctx).Info("blocked connection to ", destination)
|
||||
h.logger.InfoContext(ctx, "blocked connection to ", destination)
|
||||
return nil, io.EOF
|
||||
}
|
||||
|
||||
func (h *Block) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
|
||||
h.logger.WithContext(ctx).Info("blocked packet connection to ", destination)
|
||||
h.logger.InfoContext(ctx, "blocked packet connection to ", destination)
|
||||
return nil, io.EOF
|
||||
}
|
||||
|
||||
func (h *Block) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext) error {
|
||||
conn.Close()
|
||||
h.logger.WithContext(ctx).Info("blocked connection to ", metadata.Destination)
|
||||
h.logger.InfoContext(ctx, "blocked connection to ", metadata.Destination)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Block) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata adapter.InboundContext) error {
|
||||
conn.Close()
|
||||
h.logger.WithContext(ctx).Info("blocked packet connection to ", metadata.Destination)
|
||||
h.logger.InfoContext(ctx, "blocked packet connection to ", metadata.Destination)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user