Compare commits
2 Commits
3e9e17323d
...
4bf639f080
| Author | SHA1 | Date | |
|---|---|---|---|
| 4bf639f080 | |||
| a10b632f9d |
@@ -1,7 +1,7 @@
|
|||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Auth: alex
|
// Auth: alex
|
||||||
// File: client.go
|
// File: client.go
|
||||||
// Revn: 09-12-2026 3.0.2
|
// Revn: 09-15-2026 3.0.3
|
||||||
// Func: ask server for a message of the day quote
|
// Func: ask server for a message of the day quote
|
||||||
//
|
//
|
||||||
// TODO: remove ioutil import
|
// TODO: remove ioutil import
|
||||||
@@ -46,7 +46,11 @@
|
|||||||
// 09-07-2026: added fatih/color import
|
// 09-07-2026: added fatih/color import
|
||||||
// rewrote quoteAnswer() to handle coloring escape
|
// rewrote quoteAnswer() to handle coloring escape
|
||||||
// sequences
|
// sequences
|
||||||
// 09-12-2026: commented quoteAnswer()
|
//*09-12-2026: commented quoteAnswer()
|
||||||
|
//*09-15-2026: added -c flag and color code example printing
|
||||||
|
// changed edit command to be add and then remove instead
|
||||||
|
// of remove and then add, fixing server OOB error when
|
||||||
|
// editting only quote in list
|
||||||
//
|
//
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
@@ -242,7 +246,7 @@ func quoteAnswer( subcom []string ) string {
|
|||||||
|
|
||||||
c.Println() // print final newline
|
c.Println() // print final newline
|
||||||
|
|
||||||
fmt.Println( subcom[0] ) // whole-ass just print quote
|
//fmt.Println( subcom[0] ) // whole-ass just print quote
|
||||||
return "te@success" // set transaction end message
|
return "te@success" // set transaction end message
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,16 +392,18 @@ func secondEdit( subcom []string ) string {
|
|||||||
return "te@success"
|
return "te@success"
|
||||||
}
|
}
|
||||||
|
|
||||||
// edit command is a removal and an add
|
// edit command is an add and then a removal
|
||||||
var resp string
|
var resp string
|
||||||
resp = "cr@r2@" + subcom[0] + "@ar@"
|
resp = "cr@ar@"
|
||||||
// server response is text to be edited
|
|
||||||
fmt.Println( "as is: " + subcom[1] )
|
fmt.Println( "as is: " + subcom[1] )
|
||||||
fmt.Print( "preview: " ) // won't be useful until pretty print
|
fmt.Print( "preview: " ) // show raw of current quote
|
||||||
_ = quoteAnswer( subcom[1:] ) // display quote properly
|
_ = quoteAnswer( subcom[1:] ) // display quote properly
|
||||||
|
|
||||||
// get user input for new quote and send
|
// server response is user input for new quote
|
||||||
resp = resp + in( "\nupdate -> " )
|
resp = resp + in( "\nupdate -> " )
|
||||||
|
// and position of old quote to be removed
|
||||||
|
resp = resp + "@r2@" + subcom[0]
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,6 +564,7 @@ var add bool // add new quotes to quote file ( on server )
|
|||||||
var remove bool // remove quotes from quote file ( on server )
|
var remove bool // remove quotes from quote file ( on server )
|
||||||
var list bool // request entire quote file from server
|
var list bool // request entire quote file from server
|
||||||
var edit bool // edit a pre-existing quote from quote file ( on server )
|
var edit bool // edit a pre-existing quote from quote file ( on server )
|
||||||
|
var co bool // list color codes
|
||||||
var dest string // provide a new destination ip and port
|
var dest string // provide a new destination ip and port
|
||||||
var tsize int // size of transmission buffer
|
var tsize int // size of transmission buffer
|
||||||
var VERS string // version
|
var VERS string // version
|
||||||
@@ -568,18 +575,19 @@ func main() {
|
|||||||
var vv bool // big version flag
|
var vv bool // big version flag
|
||||||
|
|
||||||
// define flags
|
// define flags
|
||||||
flag.BoolVar( &add, "a", false, "add quote to list" )
|
flag.BoolVar( &add, "a", false, "add quote to list" )
|
||||||
flag.BoolVar( &remove, "r", false, "remove quote from list" )
|
flag.BoolVar( &remove, "r", false, "remove quote from list" )
|
||||||
flag.BoolVar( &list, "l", false, "print quote list" )
|
flag.BoolVar( &list, "l", false, "print quote list" )
|
||||||
flag.BoolVar( &edit, "e", false, "edit quote from list" )
|
flag.BoolVar( &edit, "e", false, "edit quote from list" )
|
||||||
flag.StringVar( &dest, "ip", "127.0.0.1:1300", "ip:port of server" )
|
flag.BoolVar( &co, "c", false, "list color codes with examples" )
|
||||||
flag.IntVar( &tsize, "s", 256, "transmission size ( bytes )" )
|
flag.StringVar( &dest, "ip", "127.0.0.1:1300", "ip:port of server" )
|
||||||
flag.BoolVar( &v, "v", false, "display version and exit" )
|
flag.IntVar( &tsize, "s", 256, "transmission size ( bytes )" )
|
||||||
flag.BoolVar( &vv, "vv", false, "display version and about info and exit" )
|
flag.BoolVar( &v, "v", false, "display version and exit" )
|
||||||
|
flag.BoolVar( &vv, "vv", false, "display version and about info and exit" )
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// FIXME get better versioning method
|
// FIXME get better versioning method
|
||||||
VERS = "3.0.2"
|
VERS = "3.0.3"
|
||||||
|
|
||||||
if vv { // display info and exit
|
if vv { // display info and exit
|
||||||
fmt.Println( "ekho client v" + VERS )
|
fmt.Println( "ekho client v" + VERS )
|
||||||
@@ -592,6 +600,54 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if co { // display color codes and examples and quit
|
||||||
|
// print color code and color example on same line
|
||||||
|
// color.XYZ print inserts newline
|
||||||
|
fmt.Print( "$1: " )
|
||||||
|
color.Red( "red" )
|
||||||
|
fmt.Print( "$2: " )
|
||||||
|
color.Yellow( "yellow" )
|
||||||
|
fmt.Print( "$3: " )
|
||||||
|
color.Green( "green" )
|
||||||
|
fmt.Print( "$4: " )
|
||||||
|
color.Blue( "blue" )
|
||||||
|
fmt.Print( "$5: " )
|
||||||
|
color.Cyan( "cyan" )
|
||||||
|
fmt.Print( "$6: " )
|
||||||
|
color.Magenta( "magenta" )
|
||||||
|
fmt.Print( "$7: " )
|
||||||
|
color.Black( "black" )
|
||||||
|
fmt.Print( "$0: " )
|
||||||
|
color.White( "white (reset)" )
|
||||||
|
// print bold codes
|
||||||
|
fmt.Print( "\n#1: " )
|
||||||
|
// create bold color object, change out actual color and print
|
||||||
|
bold := color.New( color.Bold, color.FgRed )
|
||||||
|
bold.Println( "bold red" )
|
||||||
|
fmt.Print( "#2: " )
|
||||||
|
bold.Add( color.FgYellow )
|
||||||
|
bold.Println( "bold yellow" )
|
||||||
|
fmt.Print( "#3: " )
|
||||||
|
bold.Add( color.FgGreen )
|
||||||
|
bold.Println( "bold green" )
|
||||||
|
fmt.Print( "#4: " )
|
||||||
|
bold.Add( color.FgBlue )
|
||||||
|
bold.Println( "bold blue" )
|
||||||
|
fmt.Print( "#5: " )
|
||||||
|
bold.Add( color.FgCyan )
|
||||||
|
bold.Println( "bold Cyan" )
|
||||||
|
fmt.Print( "#6: " )
|
||||||
|
bold.Add( color.FgMagenta )
|
||||||
|
bold.Println( "bold magenta" )
|
||||||
|
fmt.Print( "#7: " )
|
||||||
|
bold.Add( color.FgBlack )
|
||||||
|
bold.Println( "bold black" )
|
||||||
|
fmt.Print( "#0: " )
|
||||||
|
bold.Add( color.FgWhite )
|
||||||
|
bold.Println( "bold white" )
|
||||||
|
return // bail
|
||||||
|
}
|
||||||
|
|
||||||
service := dest // declare server ip:port
|
service := dest // declare server ip:port
|
||||||
|
|
||||||
// create address object
|
// create address object
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Auth: alex
|
// Auth: alex
|
||||||
// File: server.go
|
// File: server.go
|
||||||
// Revn: 09-12-2026 3.0.1
|
// Revn: 09-15-2026 3.0.2
|
||||||
// Func: host MOTD connection
|
// Func: host MOTD connection
|
||||||
//
|
//
|
||||||
// TODO: add user-specific prints
|
// TODO: add user-specific prints
|
||||||
// write usage and errors to logfile
|
// write usage and errors to logfile
|
||||||
// remove ioutil import
|
// remove ioutil import
|
||||||
// send logfile to client on request
|
// send logfile to client on request
|
||||||
// add color printing to qfile
|
|
||||||
// add flags?
|
// add flags?
|
||||||
// add more /codes/ to handle
|
// add more /codes/ to handle
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
@@ -53,6 +52,8 @@
|
|||||||
// 09-05-2026: buncha shit happened, dropped the commit
|
// 09-05-2026: buncha shit happened, dropped the commit
|
||||||
//#09-06-2026: added /e1/, /e2/, and /cr/, got edit working
|
//#09-06-2026: added /e1/, /e2/, and /cr/, got edit working
|
||||||
// 09-12-2026: minor comments in receive()
|
// 09-12-2026: minor comments in receive()
|
||||||
|
//*09-15-2026: fixed OOB error in /qa/ for perhaps the last time
|
||||||
|
// fixed bad Atoi conversion bug for perhaps the last time
|
||||||
//
|
//
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ func handle( command []string ) string {
|
|||||||
case "qr": // /qr/, quote request
|
case "qr": // /qr/, quote request
|
||||||
// convert message argument to string to make sure it's a
|
// convert message argument to string to make sure it's a
|
||||||
// valid number
|
// valid number
|
||||||
num, nerr := strconv.Atoi( command[0] )
|
num, nerr := strconv.Atoi( command[1] )
|
||||||
// nerr will not be nil if comm[1] is not a number
|
// nerr will not be nil if comm[1] is not a number
|
||||||
if nerr != nil {
|
if nerr != nil {
|
||||||
// formulate an error message
|
// formulate an error message
|
||||||
@@ -205,7 +206,7 @@ func handle( command []string ) string {
|
|||||||
// why bad? num is -
|
// why bad? num is -
|
||||||
default:
|
default:
|
||||||
// good num, get quote, send off
|
// good num, get quote, send off
|
||||||
resp = "qa@" + qlist[num - 1] // quote answer
|
resp = "qa@" + qlist[num] // quote answer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "lr": // /lr/, list request
|
case "lr": // /lr/, list request
|
||||||
@@ -453,7 +454,7 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// FIXME get better versioning method
|
// FIXME get better versioning method
|
||||||
VERS = "3.0.1"
|
VERS = "3.0.2"
|
||||||
|
|
||||||
if vv { // display info and exit
|
if vv { // display info and exit
|
||||||
fmt.Println( "ekho server v" + VERS )
|
fmt.Println( "ekho server v" + VERS )
|
||||||
|
|||||||
Reference in New Issue
Block a user