diff --git a/Gopkg.lock b/Gopkg.lock index b3014e4..1736541 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,18 +1,63 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. +[[projects]] + name = "github.com/astaxie/beego" + packages = [ + "session", + "utils" + ] + revision = "053a075344c118a5cc41981b29ef612bb53d20ca" + version = "v1.10.1" + +[[projects]] + branch = "master" + name = "github.com/google/btree" + packages = ["."] + revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306" + [[projects]] name = "github.com/gorilla/websocket" packages = ["."] revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" version = "v1.2.0" +[[projects]] + name = "github.com/klauspost/cpuid" + packages = ["."] + revision = "ae7887de9fa5d2db4eaa8174a7eff2c1ac00f2da" + version = "v1.1" + +[[projects]] + name = "github.com/klauspost/reedsolomon" + packages = ["."] + revision = "6bb6130ff6a76a904c1841707d65603aec9cc288" + version = "v1.6" + [[projects]] name = "github.com/op/go-logging" packages = ["."] revision = "b2cb9fa56473e98db8caba80237377e83fe44db5" version = "v1" +[[projects]] + name = "github.com/oschwald/maxminddb-golang" + packages = ["."] + revision = "c5bec84d1963260297932a1b7a1753c8420717a7" + version = "v1.3.0" + +[[projects]] + branch = "master" + name = "github.com/petar/GoLLRB" + packages = ["llrb"] + revision = "53be0d36a84c2a886ca057d34b6aa4468df9ccb4" + +[[projects]] + name = "github.com/pkg/errors" + packages = ["."] + revision = "645ef00459ed84a119197bfb8d8205042c6df63d" + version = "v0.8.0" + [[projects]] name = "github.com/sirupsen/logrus" packages = ["."] @@ -21,7 +66,18 @@ [[projects]] name = "github.com/skycoin/skycoin" - packages = ["src/cipher","src/cipher/base58","src/cipher/chacha20","src/cipher/ripemd160","src/cipher/secp256k1-go","src/cipher/secp256k1-go/secp256k1-go2","src/util/browser","src/util/logging"] + packages = [ + "src/cipher", + "src/cipher/base58", + "src/cipher/chacha20", + "src/cipher/go-bip39", + "src/cipher/ripemd160", + "src/cipher/secp256k1-go", + "src/cipher/secp256k1-go/secp256k1-go2", + "src/util/browser", + "src/util/file", + "src/util/logging" + ] revision = "dd924e1f2de8fab945e05b3245dbeabf267f2910" version = "v0.19.0" @@ -31,15 +87,28 @@ revision = "21fc9f95c83442fd164094666f7cb4f9fdd56cd6" version = "v1.0" +[[projects]] + branch = "master" + name = "golang.org/x/crypto" + packages = [ + "bcrypt", + "blowfish", + "pbkdf2" + ] + revision = "614d502a4dac94afa3a6ce146bd1736da82514c6" + [[projects]] branch = "master" name = "golang.org/x/sys" - packages = ["unix"] + packages = [ + "unix", + "windows" + ] revision = "d8f5ea21b9295e315e612b4bcf4bedea93454d4d" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "01b72f53d2ce3e24b19eefafcceb77d03cc6638d6433d424072efc21015e015b" + inputs-digest = "1da5c6ab264aa2c4468990a8eaa8c9a3072409cdce0505402c7db1324a79eace" solver-name = "gps-cdcl" solver-version = 1 diff --git a/skycoin-messenger/factory/conn.go b/skycoin-messenger/factory/conn.go index 8d2d2ae..d63bd1f 100644 --- a/skycoin-messenger/factory/conn.go +++ b/skycoin-messenger/factory/conn.go @@ -6,14 +6,15 @@ import ( "encoding/json" "errors" "fmt" - "github.com/skycoin/net/conn" - "github.com/skycoin/net/factory" - "github.com/skycoin/skycoin/src/cipher" "net" "strconv" "sync" "sync/atomic" "time" + + "github.com/skycoin/net/conn" + "github.com/skycoin/net/factory" + "github.com/skycoin/skycoin/src/cipher" ) type Connection struct { diff --git a/util/producer/conf.go b/util/producer/conf.go deleted file mode 100644 index 0a7c989..0000000 --- a/util/producer/conf.go +++ /dev/null @@ -1,66 +0,0 @@ -package producer - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "os" - "path/filepath" -) - -type Config struct { - AWSAccessKeyId string `json:"aws_access_key_id"` - AWSSecretKey string `json:"aws_secret_key"` - QueueURL string `json:"queue_url"` - OnlineQueueURL string `json:"online_queue_url"` - OnlineTimeQueueURL string `json:"online_time_queue_url"` - Region string `json:"region"` -} - -// LoadJsonConfig is used to load config files as json format to config. -// config should be a pointer to structure, if not, panic -func LoadConfig(conf interface{}, filename string) (err error) { - var decoder *json.Decoder - file := OpenFile(conf, filename) - defer file.Close() - decoder = json.NewDecoder(file) - if err = decoder.Decode(conf); err != nil { - return - } - json.Marshal(&conf) - return -} - -func OpenFile(conf interface{}, filename string) *os.File { - var file *os.File - var err error - - file, err = os.Open(filename) - if err != nil { - if os.IsNotExist(err) { - err = WriteConfig(conf, filename) - if err != nil { - panic(err) - } - panic(fmt.Sprintf("You should configure parameters in %s", filename)) - } - msg := fmt.Sprintf("Can not load config at %s. Error: %v", filename, err) - panic(msg) - } - - return file -} - -func WriteConfig(conf interface{}, path string) (err error) { - d, err := json.Marshal(conf) - if err != nil { - return - } - dir := filepath.Dir(path) - err = os.MkdirAll(dir, 0700) - if err != nil { - return - } - err = ioutil.WriteFile(path, d, 0600) - return -} diff --git a/util/producer/producer.go b/util/producer/producer.go deleted file mode 100644 index 361cb92..0000000 --- a/util/producer/producer.go +++ /dev/null @@ -1,130 +0,0 @@ -package producer - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/sqs" - "math/rand" - "sync" - "time" -) - -var conf *Config -var sess *session.Session -var seq uint64 = 0 -var discoveryName string -var discoveryKey string -var fieldMutex sync.RWMutex - -func Init(path, dKey string) (err error) { - conf = &Config{} - err = LoadConfig(conf, path) - if err != nil { - return - } - if len(conf.AWSSecretKey) == 0 || len(conf.AWSAccessKeyId) == 0 || len(conf.QueueURL) == 0 || len(conf.Region) == 0 { - err = fmt.Errorf("%s", "You need to fill in the correct information to ensure the discovery works.") - panic(err) - } - sess, err = session.NewSessionWithOptions(session.Options{ - Config: aws.Config{ - Credentials: credentials.NewStaticCredentials(conf.AWSAccessKeyId, conf.AWSSecretKey, ""), - Region: &conf.Region, - }, - SharedConfigState: session.SharedConfigEnable, - }) - if err != nil { - return - } - discoveryKey = dKey - discoveryName = getRandomString() - return -} - -func Close() { - conf = nil - sess = nil -} - -type MqBody struct { - Key string `json:"key"` - Seq uint64 `json:"seq"` - FromApp string `json:"from_app"` - FromNode string `json:"from_node"` - ToNode string `json:"to_node"` - ToApp string `json:"to_app"` - Uid uint64 `json:"uid"` - FromHostPort string `json:"from_host_port"` - ToHostPort string `json:"to_host_port"` - FromIp string `json:"from_ip"` - ToIp string `json:"to_ip"` - Count uint64 `json:"count"` - IsEnd bool `json:"is_end"` -} - -type MqOnline struct { - Key string `json:"key"` - Seq uint64 `json:"seq"` - Type int `json:"type"` - NodeKey string `json:"node_key"` - DiscoveryKey string `json:"discovery_key"` -} - - -func Send(body *MqBody) (err error) { - fieldMutex.Lock() - seq++ - if seq == 0 { - discoveryName = getRandomString() - seq++ - } - body.Key = discoveryName - body.Seq = seq - fieldMutex.Unlock() - svc := sqs.New(sess) - b, err := json.Marshal(&body) - if err != nil { - return - } - _, err = svc.SendMessage(&sqs.SendMessageInput{ - MessageBody: aws.String(string(b)), - QueueUrl: aws.String(conf.QueueURL), - }) - return -} - -func SendOnline(ol *MqOnline) (err error) { - fieldMutex.Lock() - seq++ - if seq == 0 { - discoveryName = getRandomString() - seq++ - } - ol.DiscoveryKey = discoveryKey - ol.Key = discoveryName - ol.Seq = seq - - fieldMutex.Unlock() - svc := sqs.New(sess) - b, err := json.Marshal(&ol) - if err != nil { - return - } - _, err = svc.SendMessage(&sqs.SendMessageInput{ - MessageBody: aws.String(string(b)), - QueueUrl: aws.String(conf.OnlineQueueURL), - }) - return -} - - -func getRandomString() string { - bytes := make([]byte, 128) - r := rand.New(rand.NewSource(time.Now().UnixNano())) - r.Read(bytes) - return hex.EncodeToString(bytes) -} diff --git a/util/producer/producer_test.go b/util/producer/producer_test.go deleted file mode 100644 index 7852383..0000000 --- a/util/producer/producer_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package producer - -import ( - "testing" - "github.com/skycoin/skycoin/src/util/file" - "path/filepath" -) - -func init() { - err := Init(filepath.Join(file.UserHome(), ".skywire", "discovery", "conf.json")) - if err != nil { - panic(err) - } -} -func TestSend(t *testing.T) { - err := Send(&MqBody{ - Key: "TestKey", - Seq: 2, - FromApp: "03c773268be29f8fe48144cc123dfd45b487dceadbb8e1d7817f84d612521bc68c", - FromNode: "03c773268be29f8fe48144ccb2c19045b487dceadbb8e1d7817f84d612521bc68c", - ToNode: "038b558e91a343c0f449b536ceab640d4055dbced85f6f5969a58ee56f2280588c", - ToApp: "03c773268be29f8zzvvcvdfcb2c19045b487dceadbb8e1d7817f84d612521bc68c", - Uid: 1, - FromHostPort: "03c773268be29fsdfdsfsdfds2c19045b487dceadbb8e1d7817f84d612521bc68c", - ToHostPort: "03c773268be29f8fe48144ccb2c19045b487dceadbb8e1d7817f84d6dzzxcxds8c", - FromIp: "03c773268be29f8fe48144ccb2c19045b487dceadbb8e1d7817f84dmmmdffasdas", - ToIp: "03c773268be29f8fe48144ccb2c19045b487dceadbb8e1d7817f84d61xzxczxsdf", - Count: 100, - IsEnd: true, - }) - //err := Send("03c773268be29f8fe48144ccb2c19045b487dceadbb8e1d7817f84d612521bc68c", "038b558e91a343c0f449b536ceab640d4055dbced85f6f5969a58ee56f2280588c", 100) - if err != nil { - panic(err) - return - } -}