Skip to content

Commit 2f734bd

Browse files
committed
updated
1 parent 32ed4de commit 2f734bd

4 files changed

Lines changed: 29 additions & 10 deletions

File tree

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ require (
116116
github.com/sirupsen/logrus v1.4.2
117117
github.com/soniah/gosnmp v1.25.0
118118
github.com/streadway/amqp v0.0.0-20180528204448-e5adc2ada8b8
119-
github.com/stretchr/testify v1.5.1
119+
github.com/stretchr/objx v0.3.0 // indirect
120+
github.com/stretchr/testify v1.6.1
120121
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62
121122
github.com/tedsuo/ifrit v0.0.0-20191009134036-9a97d0632f00 // indirect
122123
github.com/tidwall/gjson v1.6.0
@@ -148,7 +149,8 @@ require (
148149
gopkg.in/ldap.v3 v3.1.0
149150
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
150151
gopkg.in/olivere/elastic.v5 v5.0.70
151-
gopkg.in/yaml.v2 v2.2.5
152+
gopkg.in/yaml.v2 v2.3.0
153+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
152154
gotest.tools v2.2.0+incompatible // indirect
153155
honnef.co/go/tools v0.0.1-2020.1.3 // indirect
154156
k8s.io/apimachinery v0.17.1 // indirect

go.sum

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,17 @@ github.com/streadway/amqp v0.0.0-20180528204448-e5adc2ada8b8/go.mod h1:1WNBiOZtZ
539539
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
540540
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
541541
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
542+
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
543+
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
542544
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
543545
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
544546
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
545547
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
546548
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
547549
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
548550
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
551+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
552+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
549553
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 h1:Oj2e7Sae4XrOsk3ij21QjjEgAcVSeo9nkp0dI//cD2o=
550554
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62/go.mod h1:qUzPVlSj2UgxJkVbH0ZwuuiR46U8RBMDT5KLY78Ifpw=
551555
github.com/tedsuo/ifrit v0.0.0-20191009134036-9a97d0632f00 h1:mujcChM89zOHwgZBBNr5WZ77mBXP1yR+gLThGCYZgAg=
@@ -592,10 +596,10 @@ golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACk
592596
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
593597
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
594598
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
599+
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
595600
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
596601
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
597602
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
598-
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
599603
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g=
600604
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
601605
golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72 h1:+ELyKg6m8UBf0nPFSqD0mi7zUfwPyXo23HNjMnXPz7w=
@@ -702,8 +706,8 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
702706
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
703707
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
704708
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
705-
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
706709
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
710+
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
707711
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 h1:ng0gs1AKnRRuEMZoTLLlbOd+C17zUDepwGQBb/n+JVg=
708712
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
709713
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -877,6 +881,12 @@ gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
877881
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
878882
gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c=
879883
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
884+
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
885+
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
886+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
887+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
888+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
889+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
880890
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
881891
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
882892
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

plugins/inputs/opcua/opcua_client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ func Connect(o *OpcUA) error {
291291

292292
o.setupOptions()
293293

294+
log.Printf("opts: \n%d", len(o.opts))
295+
294296
o.client = opcua.NewClient(o.Endpoint, o.opts...)
295297
if err := o.client.Connect(o.ctx); err != nil {
296298
return fmt.Errorf("Error in Client Connection: %s", err)

plugins/inputs/opcua/opcua_util.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func generateCert(host string, rsaBits int, certFile, keyFile string, dur time.D
6565
template := x509.Certificate{
6666
SerialNumber: serialNumber,
6767
Subject: pkix.Name{
68-
Organization: []string{"Gopcua Test Client"},
68+
Organization: []string{"Telegraf Client Self-Signed"},
6969
},
7070
NotBefore: notBefore,
7171
NotAfter: notAfter,
@@ -153,10 +153,12 @@ func generateClientOpts(endpoints []*ua.EndpointDescription, certFile, keyFile,
153153
opts := []opcua.Option{}
154154
appuri := "urn:gopcua:client"
155155

156-
// ApplicationURI is automatically read from the cert so is not required if a cert if provided
157-
if certFile == "" {
158-
opts = append(opts, opcua.ApplicationURI(appuri))
159-
}
156+
opts = append(opts, opcua.ApplicationURI(appuri))
157+
opts = append(opts, opcua.ApplicationName("Telegraf"))
158+
// opts = append(opts, opcua.ProductURI("urn:telegraf:client"))
159+
// opts = append(opts, opcua.Lifetime(time.Hour*1))
160+
// opts = append(opts, opcua.SessionName("telegraf-opcua"))
161+
log.Printf("opts appuri: %d", len(opts))
160162

161163
if certFile == "" && keyFile == "" {
162164
if policy != "None" || mode != "None" {
@@ -177,6 +179,7 @@ func generateClientOpts(endpoints []*ua.EndpointDescription, certFile, keyFile,
177179
}
178180
cert = c.Certificate[0]
179181
opts = append(opts, opcua.PrivateKey(pk), opcua.Certificate(cert))
182+
log.Printf("opts cert: %d", len(opts))
180183
}
181184
}
182185

@@ -197,6 +200,7 @@ func generateClientOpts(endpoints []*ua.EndpointDescription, certFile, keyFile,
197200
// Select the most appropriate authentication mode from server capabilities and user input
198201
authMode, authOption := generateAuth(auth, cert, username, password)
199202
opts = append(opts, authOption)
203+
log.Printf("opts authOption: %d", len(opts))
200204

201205
var secMode ua.MessageSecurityMode
202206
switch strings.ToLower(mode) {
@@ -268,8 +272,9 @@ func generateClientOpts(endpoints []*ua.EndpointDescription, certFile, keyFile,
268272
}
269273

270274
opts = append(opts, opcua.SecurityFromEndpoint(serverEndpoint, authMode))
275+
log.Printf("opts security: %d", len(opts))
271276

272-
log.Printf("Using config:\nEndpoint: %s\nSecurity mode: %s, %s\nAuth mode : %s\n", serverEndpoint.EndpointURL, serverEndpoint.SecurityPolicyURI, serverEndpoint.SecurityMode, authMode)
277+
log.Printf("Using config:\nEndpoint: %s\nSecurity mode: %s, %s\nAuth mode: %s\n", serverEndpoint.EndpointURL, serverEndpoint.SecurityPolicyURI, serverEndpoint.SecurityMode, authMode)
273278
return opts
274279
}
275280

0 commit comments

Comments
 (0)