Skip to content

Commit

Permalink
v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhoublue committed Nov 9, 2022
1 parent d6239fc commit 0de07d9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.2
v0.0.3
4 changes: 2 additions & 2 deletions charts/smartdocter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ home: "https://spidernet-io.github.io/smartdocter"
# application or library
type: application
# no need to modify this version , CI will auto update it with /VERSION
version: v0.0.1
version: v0.0.3
# This field is informational, and has no impact on chart version calculations .
# Leaving it unquoted can lead to parsing issues in some cases
# no need to modify this version , CI will auto update it with /VERSION
appVersion: "v0.0.1"
appVersion: "v0.0.3"
kubeVersion: ">= 1.16.0-0"
description: smart docter for kubernetes
sources:
Expand Down
25 changes: 20 additions & 5 deletions smartdocter-agent-cmd/serve-hostname/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ package main

import (
"fmt"
"github.com/spf13/cobra"
"log"
"net"
"net/http"
"os"
"os/signal"
"syscall"
"time"

"github.com/spf13/cobra"
)

// CmdServeHostname is used by agnhost Cobra.
Expand All @@ -56,7 +55,7 @@ func init() {
CmdServeHostname.Flags().BoolVar(&doUDP, "udp", false, "Serve raw over UDP.")
CmdServeHostname.Flags().BoolVar(&doHTTP, "http", true, "Serve HTTP.")
CmdServeHostname.Flags().BoolVar(&doClose, "close", false, "Close connection per each HTTP request.")
CmdServeHostname.Flags().IntVar(&port, "port", 9376, "Port number.")
CmdServeHostname.Flags().IntVar(&port, "port", 80, "Port number.")
}

func rootmain(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -124,8 +123,24 @@ func rootmain(cmd *cobra.Command, args []string) {
// Add this header to force to close the connection after serving the request.
w.Header().Add("Connection", "close")
}
res := "server: " + hostname + ", client: " + r.RemoteAddr
fmt.Fprintf(w, "%s", res)
message := "{ \n"
message += fmt.Sprintf(" \"server\": \"%s\"\n", hostname)
message += fmt.Sprintf(" \"clientIp\": \"%s\"\n", r.RemoteAddr)
message += "}"
fmt.Fprintf(w, "%s", message)

message = "\n"
message += "{ \n"
message += fmt.Sprintf(" \"request method\": \"%s\"\n", r.Method)
message += fmt.Sprintf(" \"request url\": \"%s\"\n", r.RequestURI)
message += " \"request header\": {\n"
for k, v := range r.Header {
message += fmt.Sprintf(" \"%s\": \"%s\"\n", k, v)
}
message += " }\n"
message += "}"
fmt.Fprintf(w, "%s", message)

})
go func() {
// Run in a closure so http.ListenAndServe doesn't block
Expand Down

0 comments on commit 0de07d9

Please sign in to comment.