1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00
This commit is contained in:
Darien Raymond 2017-04-28 14:48:23 +02:00
parent 7f1e9c85c9
commit 693702350d
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
6 changed files with 16 additions and 25 deletions

View File

@ -3,15 +3,15 @@ package crypto
import (
"crypto/aes"
"crypto/cipher"
"v2ray.com/core/common"
)
// NewAesDecryptionStream creates a new AES encryption stream based on given key and IV.
// Caller must ensure the length of key and IV is either 16, 24 or 32 bytes.
func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream {
aesBlock, err := aes.NewCipher(key)
if err != nil {
panic(err)
}
common.Must(err)
return cipher.NewCFBDecrypter(aesBlock, iv)
}
@ -19,8 +19,6 @@ func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream {
// Caller must ensure the length of key and IV is either 16, 24 or 32 bytes.
func NewAesEncryptionStream(key []byte, iv []byte) cipher.Stream {
aesBlock, err := aes.NewCipher(key)
if err != nil {
panic(err)
}
common.Must(err)
return cipher.NewCFBEncrypter(aesBlock, iv)
}

View File

@ -5,15 +5,14 @@ import (
"encoding/hex"
"testing"
"v2ray.com/core/common"
. "v2ray.com/core/common/crypto"
"v2ray.com/core/testing/assert"
)
func mustDecodeHex(s string) []byte {
b, err := hex.DecodeString(s)
if err != nil {
panic(err)
}
common.Must(err)
return b
}

View File

@ -4,15 +4,14 @@ import (
"net"
"testing"
"v2ray.com/core/common"
. "v2ray.com/core/common/net"
"v2ray.com/core/testing/assert"
)
func parseCIDR(str string) *net.IPNet {
_, ipNet, err := net.ParseCIDR(str)
if err != nil {
panic(err)
}
common.Must(err)
return ipNet
}

View File

@ -81,17 +81,14 @@ var (
func genTestBinaryPath() {
testBinaryPathGen.Do(func() {
var tempDir string
err := retry.Timed(5, 100).On(func() error {
common.Must(retry.Timed(5, 100).On(func() error {
dir, err := ioutil.TempDir("", "v2ray")
if err != nil {
return err
}
tempDir = dir
return nil
})
if err != nil {
panic(err)
}
}))
file := filepath.Join(tempDir, "v2ray.test")
if runtime.GOOS == "windows" {
file += ".exe"

View File

@ -11,6 +11,8 @@ import (
"path/filepath"
"runtime"
"strings"
"v2ray.com/core/common"
)
var protocMap = map[string]string{
@ -64,7 +66,7 @@ func main() {
}
}
err := filepath.Walk(reporoot, func(path string, info os.FileInfo, err error) error {
common.Must(filepath.Walk(reporoot, func(path string, info os.FileInfo, err error) error {
if err != nil {
fmt.Println(err)
return err
@ -90,8 +92,5 @@ func main() {
}
return nil
})
if err != nil {
panic(err)
}
}))
}

View File

@ -14,6 +14,7 @@ import (
"strings"
"v2ray.com/core/app/router"
"v2ray.com/core/common"
"v2ray.com/core/common/errors"
"v2ray.com/core/tools/geoip"
@ -26,9 +27,7 @@ const (
func main() {
resp, err := http.Get(apnicFile)
if err != nil {
panic(err)
}
common.Must(err)
if resp.StatusCode != 200 {
panic(errors.New("unexpected status ", resp.StatusCode))
}