2023-01-27 01:10:27 +07:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2023-01-28 12:56:06 +07:00
|
|
|
* Copyright (c) since 2023, v2rayA Organization <team@v2raya.org>
|
2023-01-27 01:10:27 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
package dialer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
2023-02-09 12:27:59 +07:00
|
|
|
type blockDialer struct {
|
|
|
|
DialCallback func()
|
|
|
|
}
|
2023-01-27 01:10:27 +07:00
|
|
|
|
2023-02-09 12:27:59 +07:00
|
|
|
func (d *blockDialer) Dial(network string, addr string) (c net.Conn, err error) {
|
|
|
|
d.DialCallback()
|
2023-01-27 01:10:27 +07:00
|
|
|
return nil, net.ErrClosed
|
|
|
|
}
|
|
|
|
|
2023-02-09 12:27:59 +07:00
|
|
|
func NewBlockDialer(option *GlobalOption, dialCallback func()) *Dialer {
|
|
|
|
return NewDialer(&blockDialer{DialCallback: dialCallback}, option, InstanceOption{CheckEnabled: false}, "block", "block", "")
|
2023-01-27 01:10:27 +07:00
|
|
|
}
|