Added source and prebuilds

This commit is contained in:
ultimateplayer1999 2023-01-10 15:57:26 +01:00
parent 192cf8bd75
commit 84c7831e7c
Signed by: ultimateplayer1999
GPG Key ID: 690D4E43F8B51E51
11 changed files with 242 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.env
go.sum
go.mod
stats.go
stats

View File

@ -1 +1,3 @@
Some examples for API usage in Go for the ssh.surf API
All of them based on .env files

BIN
containerinfo Executable file

Binary file not shown.

47
containerinfo.go Normal file
View File

@ -0,0 +1,47 @@
package main
import (
"net/http"
"log"
"fmt"
"os"
"io/ioutil"
"github.com/joho/godotenv"
)
func main() {
// Load environment variables from .env file
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
token := os.Getenv("TOKEN")
// Make an HTTP request to api.discord-linux.com
req, err := http.NewRequest("GET", "https://api.discord-linux.com/info", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Add("Content-Type", "Application/json")
req.Header.Add("x-discord-linux-auth", token)
client := http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
fmt.Println("Status code: ", resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(body))
}

BIN
containertime Executable file

Binary file not shown.

47
containertime.go Normal file
View File

@ -0,0 +1,47 @@
package main
import (
"net/http"
"log"
"fmt"
"os"
"io/ioutil"
"github.com/joho/godotenv"
)
func main() {
// Load environment variables from .env file
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
token := os.Getenv("TOKEN")
// Make an HTTP request to api.discord-linux.com
req, err := http.NewRequest("GET", "https://api.discord-linux.com/time", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Add("Content-Type", "Application/json")
req.Header.Add("x-discord-linux-auth", token)
client := http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
fmt.Println("Status code: ", resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(body))
}

47
hello.go Normal file
View File

@ -0,0 +1,47 @@
package main
import (
"net/http"
"log"
"fmt"
"os"
"io/ioutil"
"github.com/joho/godotenv"
)
func main() {
// Load environment variables from .env file
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
token := os.Getenv("TOKEN")
// Make an HTTP request to api.discord-linux.com
req, err := http.NewRequest("GET", "https://api.discord-linux.com/hello", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Add("Content-Type", "Application/json")
req.Header.Add("x-discord-linux-auth", token)
client := http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
fmt.Println("Status code: ", resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(body))
}

BIN
keystatus Executable file

Binary file not shown.

47
keystatus.go Normal file
View File

@ -0,0 +1,47 @@
package main
import (
"net/http"
"log"
"fmt"
"os"
"io/ioutil"
"github.com/joho/godotenv"
)
func main() {
// Load environment variables from .env file
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
token := os.Getenv("TOKEN")
// Make an HTTP request to api.discord-linux.com
req, err := http.NewRequest("GET", "https://api.discord-linux.com/key-time", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Add("Content-Type", "Application/json")
req.Header.Add("x-discord-linux-auth", token)
client := http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
fmt.Println("Status code: ", resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(body))
}

BIN
newkey Executable file

Binary file not shown.

47
newkey.go Normal file
View File

@ -0,0 +1,47 @@
package main
import (
"net/http"
"log"
"fmt"
"os"
"io/ioutil"
"github.com/joho/godotenv"
)
func main() {
// Load environment variables from .env file
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
token := os.Getenv("TOKEN")
// Make an HTTP request to api.discord-linux.com
req, err := http.NewRequest("GET", "https://api.discord-linux.com/new-key", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Add("Content-Type", "Application/json")
req.Header.Add("x-discord-linux-auth", token)
client := http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
fmt.Println("Status code: ", resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(body))
}