adding version to code
This commit is contained in:
31
main.go
31
main.go
@@ -8,14 +8,31 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
const version = "0.1"
|
||||||
display := os.Getenv("DISPLAY")
|
|
||||||
proxySocket := "/tmp/.X11-unix/X5"
|
|
||||||
|
|
||||||
overrideDisplay := flag.String("display", "", "Override DISPLAY")
|
var (
|
||||||
overrideSocket := flag.String("proxy-socket", proxySocket, "Proxy socket path")
|
overrideDisplay = flag.String("display", "", "Override DISPLAY")
|
||||||
|
overrideSocket = flag.String("proxy-socket", "/tmp/.X11-unix/X5", "Proxy socket path")
|
||||||
|
showVersion = flag.Bool("version", false, "Show version and exit")
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.Usage = func() {
|
||||||
|
fmt.Fprintf(os.Stderr, "Usage of %s:\n\n", os.Args[0])
|
||||||
|
flag.PrintDefaults()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *showVersion {
|
||||||
|
fmt.Printf("X11Proxy version %s\n", version)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Printf("version %s\n", version)
|
||||||
|
|
||||||
|
display := os.Getenv("DISPLAY")
|
||||||
if *overrideDisplay != "" {
|
if *overrideDisplay != "" {
|
||||||
display = *overrideDisplay
|
display = *overrideDisplay
|
||||||
}
|
}
|
||||||
@@ -41,7 +58,6 @@ func hexDump(buf []byte) string {
|
|||||||
for i := 0; i < len(buf); i += 16 {
|
for i := 0; i < len(buf); i += 16 {
|
||||||
line := fmt.Sprintf("%08x ", i)
|
line := fmt.Sprintf("%08x ", i)
|
||||||
|
|
||||||
// Hex section
|
|
||||||
for j := 0; j < 16; j++ {
|
for j := 0; j < 16; j++ {
|
||||||
if i+j < len(buf) {
|
if i+j < len(buf) {
|
||||||
line += fmt.Sprintf("%02x ", buf[i+j])
|
line += fmt.Sprintf("%02x ", buf[i+j])
|
||||||
@@ -49,13 +65,12 @@ func hexDump(buf []byte) string {
|
|||||||
line += " "
|
line += " "
|
||||||
}
|
}
|
||||||
if j == 7 {
|
if j == 7 {
|
||||||
line += " " // extra space in middle
|
line += " "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line += " |"
|
line += " |"
|
||||||
|
|
||||||
// ASCII section
|
|
||||||
for j := 0; j < 16 && i+j < len(buf); j++ {
|
for j := 0; j < 16 && i+j < len(buf); j++ {
|
||||||
b := buf[i+j]
|
b := buf[i+j]
|
||||||
if b >= 32 && b <= 126 {
|
if b >= 32 && b <= 126 {
|
||||||
|
|||||||
Reference in New Issue
Block a user