what "unknown tls.Config field" Error Means? - go

While I compile a go language code using "go install", I got the following error:
./xyzcheck.go:34: unknown tls.Config field 'EarlyCCS' in struct literal
here is the code that make that error
conn, err = tls.Dial("tcp", target, &tls.Config{InsecureSkipVerify: true, EarlyCCS: 2})
if err == nil {
fmt.Printf("\x1b[31mXYZ Check is OK.\x1b[0m\n")
os.Exit(1)
}
I googled this error but no luck.
If anyone can tell me what is the reason for this error? and how can I fix it. it will be great.
Thanks

ABC: 2 is not a valid parameter for config. There is documentation on config settings for tls here: http://golang.org/pkg/crypto/tls/#Config

The author has a patch that needs to be applied to the tls package. This was clearly explained on his blog page where you obtained this script.
Apply the patch to the tls package, re-run the script and it will work.

Related

How to fix: Chromedriver Page Immediately Closes

I run a program that tries to open a webpage using agouti/chromedriver in go, but as soon as it calls the new page, it closes the page. Subsequent attempts to access the page result in an "invalid session id" error. How can I get the page to stay open?
This is using Go (version 1.13.3 darwin/amd64) on Mac (version 10.14.5), with chromedriver (version 76.0.3809.68). I have the latest version of Google Chrome installed as well. I have tried updating chrome and agouti to no improved results. I have quit and restarted Chrome, uninstalled and reinstalled Chrome, and restarted my computer, none of which have worked. I have run with several chromedriver options (seen below), and run without them. I have tried with (seen below) and without time.Sleep() between functions. My regular chrome browser works fine.
package main
import (
"fmt"
"time"
"github.com/sclevine/agouti"
)
func main() {
driver := agouti.ChromeDriver(
agouti.ChromeOptions("args", []string{
"--headless",
"--no-sandbox",
"--disable-dev-shm-usage",
"--disable-gpu",
"--whitelisted-ips",
"--detach",
}),
agouti.Debug,
)
fmt.Println("start")
err := driver.Start()
if err != nil {
fmt.Println("Error starting driver: " + err.Error())
return
}
page, err := driver.NewPage(agouti.Browser("chrome"))
if err != nil {
fmt.Println("Error creating new page: " + err.Error())
return
}
time.Sleep(1 * time.Second)
err = page.Navigate("https://www.google.com")
if err != nil {
fmt.Println("Error navigating to job post link: " + err.Error())
return
}
time.Sleep(1 * time.Second)
fmt.Println("end")
}
When not using the --headless tag, I can see the browser window open and close in less than a second.
Expected output:
start
Starting ChromeDriver 76.0.3809.68 (420c9498db8ce8fcd190a954d51297672c1515d5-refs/branch-heads/3809#{#864}) on port 53489
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
end
Actual Output:
start
Starting ChromeDriver 76.0.3809.68 (420c9498db8ce8fcd190a954d51297672c1515d5-refs/branch-heads/3809#{#864}) on port 53489
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Error navigating to job post link: failed to navigate: request unsuccessful: invalid session id
I found the solution; turns out I needed to reinstall chromedriver. Looking back through my logs, the issue occurred due to Chrome automatically updating overnight, and no longer working with my previous version of chromedriver.

telegraf output to Elasticsearch: "health check timeout: no Elasticsearch node available"

I'm having trouble connecting to an Elasticsearch instance with a Telegraf output plugin.
I created an Elasticsearch setup via the Elasticsearch service. I created a user and password (connected to a role) in Kibana for it.
Then I setup a Telegraf output for it:
[[outputs.elasticsearch]]
urls = [ "https://hostname:port" ] # required.
timeout = "5s"
enable_sniffer = false
health_check_interval = "10s"
## HTTP basic authentication details.
username = "my_username"
password = "my_password"
index_name = "device_logs" # required.
insecure_skip_verify = true
manage_template = true
template_name = "telegraf"
overwrite_template = false
But when I try to start Telegraf with this, it just gives the error,
[agent] Failed to connect to [outputs.elasticsearch], retrying in 15s, error was 'health check timeout: no Elasticsearch node available'
The connect fail seems to originate deep in the bowels of golang's net/http library, and I don't know how to get some more useful output at this point.
Things I've tried:
Thing #1: I tested cURL:
curl -u my_username:my_password -X POST "https://hostname:port/device_logs/_doc" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}'
This works fine.
Thing #2: I created a simple Go program to connect to elasticsearch from Go:
package main
import (
"log"
"time"
"gopkg.in/olivere/elastic.v3"
)
func main() {
// configure connection to ES
client, err := elastic.NewClient(elastic.SetURL("https://hostname:port"))
if err != nil {
panic(err)
}
log.Printf("client.running? %v",client.IsRunning())
if ! client.IsRunning() {
panic("Could not make connection, not running")
}
}
.. and it hits the first panic with the same "no Elasticsearch node available".
Thing #3: I tried running gdb on that Go program to debug into it.
It jumps down to assembly as soon as I call NewClient, so I can't really learn what is happening in the bowels of net/http.
I've never used Go before, so I'm hoping to avoid hours of learning Go, spelunking, and debugging to get around what hopefully is a simple issue here.
Any ideas on how to get more info here or why this is failing? Are there build or runtime flags for Go that I can use? gdb-with-Go debugging tips so I can step down into the Go library code? Elasticsearch client know-how?
To answer my own question, the problem here turned out to be the roles permissions. The Telegraf output plugin for Elasticsearch needs both the monitor and the manage_index_templates permissions to be enabled, or else it'll fail to connect to the Elasticsearch server without printing any information about why.
BTW: to build golang code and be able to debug into the libraries it calls:
go build -gcflags=all="-N -l"

a required argument is missing: /key:[Sonarqube project key]

I am trying to run sonarqube analysis but I am getting the error
"a required argument is missing: /key:[Sonarqube project key]"
C:\Sonarqube\sonarqube-6.7\sonarqube-6.7\bin\sonar-scanner-msbuild-4.0.2.892\SonarQube.Scanner.MSBuild.exe begin /key: {projectkey} /name:{projectname} /version:{1.0}
I have used the following url
I have tried using the "" in Key and Name but still get the same error
can anyone suggest how to do this?
There's a typo in the command line: the space between /key: and {projectkey}. This is what produces this error message.

golang error: reference to undefined identifier ‘syscall.TUNSETIFF’

So, I have been trying to build flannel (https://github.com/coreos/flannel) with gccgo. Here is the error I am getting while building:
$ ./build
Building flanneld...
# github.com/coreos/flannel/pkg/ip
gopath/src/github.com/coreos/flannel/pkg/ip/tun.go:57:37: error: reference to undefined identifier ‘syscall.TUNSETIFF’
err = ioctl(int(tun.Fd()), syscall.TUNSETIFF, uintptr(unsafe.Pointer(&ifr)))
^
I am using gccgo-5 and gcc-5. Can anyone please help me figure out what exactly is the issue here? TIA
So, I found the answer. The problem was that gccgo didn't define TUNSETIFF for my arch. I defined the value accordingly and I was able to make it work. Thanks #JimB

golang: runtime error: invalid memory address or nil pointer dereference

I am new to golang and currently following this tutorial and source code here - http://golang.org/doc/articles/wiki/part2.go
After building this file, I am getting
calvin$ ./mywebwiki2
2012/07/23 17:12:59 http: panic serving [::1]:58820: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/pkg/net/http/server.go:576 (0x3f202)
_func_003: buf.Write(debug.Stack())
/private/tmp/bindist454984655/go/src/pkg/runtime/proc.c:1443 (0x10c79)
/private/tmp/bindist454984655/go/src/pkg/runtime/runtime.c:128 (0x11745)
/private/tmp/bindist454984655/go/src/pkg/runtime/thread_darwin.c:418 (0x148b5)
/Users/calvin/work/gowiki/mywebwiki2.go:33 (0x2248)
viewHandler: fmt.Fprintf(w, "<h1>%s</h1><div>%s</div>", p.Title, p.Body)
/usr/local/go/src/pkg/net/http/server.go:690 (0x331ae)
HandlerFunc.ServeHTTP: f(w, r)
/usr/local/go/src/pkg/net/http/server.go:926 (0x34030)
(*ServeMux).ServeHTTP: mux.handler(r).ServeHTTP(w, r)
/usr/local/go/src/pkg/net/http/server.go:656 (0x32fc1)
(*conn).serve: handler.ServeHTTP(w, w.req)
/private/tmp/bindist454984655/go/src/pkg/runtime/proc.c:271 (0xed7f)
2012/07/23 17:12:59 http: panic serving [::1]:58821: runtime error: invalid memory address or nil pointer dereference
Any idea what I did wrong to be causing this apparent memory corruption?
There's an ignored err at line 36. The error probably says open .txt: no such file or directory if you tested in browser using URL http://localhost:8080/view/ or open foo.txt: no such file or directory if you tested in browser using URL http://localhost:8080/view/foo. In the later case there must be a file "foo.txt" in your working directory for this example code to work. After that the code seems to work for me locally.
Someone should probably fill an issue about the ignored error value.
In the tutorial, you created the file TestPage previously. Which is the page you should be navigating to when you first build the server. In the tutorial, they have you navigate to view/test instead of view/TestPage as you should which is what creates the confusion.

Resources