Skip to content

Commit

Permalink
update by baohv
Browse files Browse the repository at this point in the history
  • Loading branch information
Phuocpr1998 committed Dec 13, 2019
1 parent 8441389 commit 2f6461c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 3 additions & 4 deletions soap.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/clbanning/mxj"
"github.com/golang/glog"
"github.com/satori/go.uuid"
"github.com/google/uuid"
)

// SOAP contains data for SOAP request
Expand Down Expand Up @@ -122,9 +122,8 @@ func (soap SOAP) createRequest() string {
}

func (soap SOAP) createUserToken() string {
u, _ := uuid.NewV4()
nonce := u.Bytes()
nonce64 := base64.StdEncoding.EncodeToString(nonce)
nonce := uuid.New().String()
nonce64 := base64.StdEncoding.EncodeToString(([]byte)(nonce))
timestamp := time.Now().Add(soap.TokenAge).UTC().Format(time.RFC3339)
token := string(nonce) + timestamp + soap.Password

Expand Down
12 changes: 7 additions & 5 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
)

var testDevice = Device{
XAddr: "http://192.168.1.231/onvif/device_service",
XAddr: "http://192.168.0.11/onvif/device_service",
User: "admin",
Password: "Admin123",
}

func interfaceToString(src interface{}) string {
Expand Down Expand Up @@ -38,17 +40,17 @@ func interfaceToFloat64(src interface{}) float64 {
return number
}

func intToString(src int) string {
func intToString(src int) string {
strInt := strconv.Itoa(src)
return strInt
}

func float64ToString(src float64) string {
func float64ToString(src float64) string {
strFloat64 := fmt.Sprint(src)
return strFloat64
}

func boolToString(src bool) string{
func boolToString(src bool) string {
if src {
return "true"
}
Expand All @@ -59,5 +61,5 @@ func boolToString(src bool) string{
// kiem tra co phai loi chung thuc hay khong
func CheckAuthorizedError(msg string) bool {
msg = strings.ToLower(msg)
return strings.Index(msg, "authorized") != -1;
return strings.Index(msg, "authorized") != -1
}

0 comments on commit 2f6461c

Please sign in to comment.