aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2021-07-28 22:37:14 +0300
committeraqua <aqua@iserlohn-fortress.net>2021-07-28 22:37:14 +0300
commit47e66d167e9b7b07c49fa880274e0cc6b001926d (patch)
tree8ebceb56117d23b578b1d4fed065f249c08bdea8
downloadgemcat-47e66d167e9b7b07c49fa880274e0cc6b001926d.tar.xz
Initial commit
-rw-r--r--go.mod3
-rw-r--r--main.go48
2 files changed, 51 insertions, 0 deletions
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..51942f3
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module gemcat
+
+go 1.16
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..cf5b69e
--- /dev/null
+++ b/main.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "crypto/tls"
+ "log"
+)
+
+const url = "gemini.circumlunar.space:1965"
+const request = "gemini://gemini.circumlunar.space/\r\n"
+
+func main() {
+ conf := tls.Config{
+ InsecureSkipVerify: true,
+ }
+
+ conn, err := tls.Dial("tcp", url, &conf)
+
+ if err != nil {
+ panic("failed to connect: " + err.Error())
+ } else {
+ log.Println("connected to " + url)
+ }
+
+ defer conn.Close()
+
+ n, err := conn.Write([]byte(request))
+ if err != nil {
+ log.Println(n, err)
+ return
+ }
+
+ buf := make([]byte, 1024)
+
+ for {
+ n, err = conn.Read(buf)
+ if err != nil {
+ log.Println(n, err)
+ return
+ } else {
+ println(string(buf[:n]))
+ }
+
+ if n == 0 {
+ break
+ }
+ }
+
+}