Browse Source

comments

pull/984/merge
Darien Raymond 7 years ago
parent
commit
27ccc9d726
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 3
      common/buf/buf.go
  2. 1
      common/buf/buffer.go
  3. 2
      common/crypto/crypto.go
  4. 2
      common/dice/dice.go
  5. 2
      common/errors/errors.go
  6. 2
      common/log/log.go
  7. 2
      common/net/net.go
  8. 2
      common/platform/platform.go
  9. 2
      common/predicate/predicate.go
  10. 2
      common/protocol/protocol.go
  11. 2
      common/retry/retry.go
  12. 8
      common/session/session.go
  13. 2
      common/uuid/uuid.go

3
common/buf/buf.go

@ -1,3 +1,4 @@
package buf
// Package buf provides a light-weight memory allocation mechanism.
package buf // import "v2ray.com/core/common/buf"
//go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg buf -path Buf

1
common/buf/buffer.go

@ -1,4 +1,3 @@
// Package buf provides a light-weight memory allocation mechanism.
package buf
import (

2
common/crypto/crypto.go

@ -1,4 +1,4 @@
// Package crypto provides common crypto libraries for V2Ray.
package crypto
package crypto // import "v2ray.com/core/common/crypto"
//go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg crypto -path Crypto

2
common/dice/dice.go

@ -1,6 +1,6 @@
// Package dice contains common functions to generate random number.
// It also initialize math/rand with the time in seconds at launch time.
package dice
package dice // import "v2ray.com/core/common/dice"
import (
"math/rand"

2
common/errors/errors.go

@ -1,5 +1,5 @@
// Package errors is a drop-in replacement for Golang lib 'errors'.
package errors
package errors // import "v2ray.com/core/common/errors"
import (
"context"

2
common/log/log.go

@ -1,4 +1,4 @@
package log
package log // import "v2ray.com/core/common/log"
import (
"sync"

2
common/net/net.go

@ -1,4 +1,4 @@
// Package net is a drop-in replacement to Golang's net package, with some more functionalities.
package net
package net // import "v2ray.com/core/common/net"
//go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg net -path Net

2
common/platform/platform.go

@ -1,4 +1,4 @@
package platform
package platform // import "v2ray.com/core/common/platform"
import (
"os"

2
common/predicate/predicate.go

@ -1,4 +1,4 @@
package predicate
package predicate // import "v2ray.com/core/common/predicate"
type Predicate func() bool

2
common/protocol/protocol.go

@ -1,3 +1,3 @@
package protocol
package protocol // import "v2ray.com/core/common/protocol"
//go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg protocol -path Protocol

2
common/retry/retry.go

@ -1,4 +1,4 @@
package retry
package retry // import "v2ray.com/core/common/retry"
//go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg retry -path Retry

8
common/session/session.go

@ -1,12 +1,16 @@
package session
// Package session provides functions for sessions of incoming requests.
package session // import "v2ray.com/core/common/session"
import (
"context"
"math/rand"
)
// ID of a session.
type ID uint32
// NewID generates a new ID. The generated ID is high likely to be unique, but not cryptographically secure.
// The generated ID will never be 0.
func NewID() ID {
for {
id := ID(rand.Uint32())
@ -22,10 +26,12 @@ const (
idSessionKey sessionKey = iota
)
// ContextWithID returns a new context with the given ID.
func ContextWithID(ctx context.Context, id ID) context.Context {
return context.WithValue(ctx, idSessionKey, id)
}
// IDFromContext returns ID in this context, or 0 if not contained.
func IDFromContext(ctx context.Context) ID {
if id, ok := ctx.Value(idSessionKey).(ID); ok {
return id

2
common/uuid/uuid.go

@ -1,4 +1,4 @@
package uuid
package uuid // import "v2ray.com/core/common/uuid"
import (
"bytes"

Loading…
Cancel
Save