fix lint errors

pull/984/merge
Darien Raymond 7 years ago
parent 27ccc9d726
commit 9f198d7e3d
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -34,10 +34,12 @@ func NewCommander(ctx context.Context, config *Config) (*Commander, error) {
return c, nil
}
// Type implements common.HasType.
func (c *Commander) Type() interface{} {
return (*Commander)(nil)
}
// Start implements common.Runnable.
func (c *Commander) Start() error {
c.Lock()
c.server = grpc.NewServer()
@ -77,6 +79,7 @@ func (c *Commander) Start() error {
return nil
}
// Close implements common.Closable.
func (c *Commander) Close() error {
c.Lock()
defer c.Unlock()

@ -52,10 +52,6 @@ func (*DefaultDispatcher) Start() error {
// Close implements common.Closable.
func (*DefaultDispatcher) Close() error { return nil }
func getStatsName(u *protocol.User) string {
return "user>traffic>" + u.Email
}
func (d *DefaultDispatcher) getStatCounter(name string) core.StatCounter {
c := d.stats.GetCounter(name)
if c != nil {

@ -7,6 +7,7 @@ import (
"github.com/miekg/dns"
"v2ray.com/core"
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/dice"
"v2ray.com/core/common/net"
@ -54,7 +55,7 @@ func NewUDPNameServer(address net.Destination, dispatcher core.Dispatcher) *UDPN
Interval: time.Minute,
Execute: s.Cleanup,
}
s.cleanup.Start()
common.Must(s.cleanup.Start())
return s
}

@ -10,22 +10,27 @@ import (
"v2ray.com/core"
)
// Counter is an implementation of core.StatCounter.
type Counter struct {
value int64
}
// Value implements core.StatCounter.
func (c *Counter) Value() int64 {
return atomic.LoadInt64(&c.value)
}
// Set implements core.StatCounter.
func (c *Counter) Set(newValue int64) int64 {
return atomic.SwapInt64(&c.value, newValue)
}
// Add implements core.StatCounter.
func (c *Counter) Add(delta int64) int64 {
return atomic.AddInt64(&c.value, delta)
}
// Manager is an implementation of core.StatManager.
type Manager struct {
access sync.RWMutex
counters map[string]*Counter

@ -124,7 +124,7 @@ func (r *AuthenticationReader) readSize() (int32, error) {
var errSoft = newError("waiting for more data")
func (r *AuthenticationReader) readInternal(soft bool) (*buf.Buffer, error) {
if soft && r.reader.BufferedBytes() < int32(r.sizeParser.SizeBytes()) {
if soft && r.reader.BufferedBytes() < r.sizeParser.SizeBytes() {
return nil, errSoft
}

@ -99,7 +99,7 @@ func (p *AddressParser) readAddress(b *buf.Buffer, reader io.Reader) (net.Addres
return nil, err
}
domainLength := int32(b.Byte(b.Len() - 1))
if err := b.AppendSupplier(buf.ReadFullFrom(reader, int32(domainLength))); err != nil {
if err := b.AppendSupplier(buf.ReadFullFrom(reader, domainLength)); err != nil {
return nil, err
}
domain := string(b.BytesFrom(-domainLength))

@ -49,15 +49,15 @@ func (u *UUID) Equals(another *UUID) bool {
// Next generates a deterministic random UUID based on this UUID.
func (u *UUID) Next() UUID {
md5hash := md5.New()
md5hash.Write(u.Bytes())
md5hash.Write([]byte("16167dc8-16b6-4e6d-b8bb-65dd68113a81"))
common.Must2(md5hash.Write(u.Bytes()))
common.Must2(md5hash.Write([]byte("16167dc8-16b6-4e6d-b8bb-65dd68113a81")))
var newid UUID
for {
md5hash.Sum(newid[:0])
if !newid.Equals(u) {
return newid
}
md5hash.Write([]byte("533eff8a-4113-4b10-b5ce-0f5d76b98cd2"))
common.Must2(md5hash.Write([]byte("533eff8a-4113-4b10-b5ce-0f5d76b98cd2")))
}
}

@ -21,7 +21,6 @@ type DokodemoDoor struct {
config *Config
address net.Address
port net.Port
v *core.Instance
}
func New(ctx context.Context, config *Config) (*DokodemoDoor, error) {

@ -41,7 +41,7 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
ivLen := account.Cipher.IVSize()
var iv []byte
if ivLen > 0 {
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, int32(ivLen))); err != nil {
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, ivLen)); err != nil {
return nil, nil, newError("failed to read IV").Base(err)
}
@ -227,7 +227,7 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload []byte) (*buf.Buff
buffer := buf.New()
ivLen := account.Cipher.IVSize()
if ivLen > 0 {
common.Must(buffer.Reset(buf.ReadFullFrom(rand.Reader, int32(ivLen))))
common.Must(buffer.Reset(buf.ReadFullFrom(rand.Reader, ivLen)))
}
iv := buffer.Bytes()
@ -293,7 +293,7 @@ func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.Reques
authenticator := NewAuthenticator(HeaderKeyGenerator(account.Key, iv))
actualAuth := make([]byte, AuthSize)
authenticator.Authenticate(payload.BytesTo(payloadLen))(actualAuth)
common.Must2(authenticator.Authenticate(payload.BytesTo(payloadLen))(actualAuth))
if !bytes.Equal(actualAuth, authBytes) {
return nil, nil, newError("invalid OTA")
}

@ -9,8 +9,5 @@ func (c *Config) Apply() error {
if c == nil {
return nil
}
if err := internet.ApplyGlobalTransportSettings(c.TransportSettings); err != nil {
return err
}
return nil
return internet.ApplyGlobalTransportSettings(c.TransportSettings)
}

Loading…
Cancel
Save