Author SHA1 Message Date
Mike Holloway a46c855960 On branch timer
Changes to be committed:
	modified:   main.go
		Add call to timer
	new file:   timer/timer.go
		New 10 second timer
2021-06-25 00:20:30 -04:00
Mike Holloway 0ea14fd132 On branch fix-colons
Changes to be committed:
	modified:   main.go
		No longer replacing colons with ','
2021-06-24 23:01:12 -04:00
Mike Holloway 7020adee58 On branch hexadecimal-and-fields
Changes to be committed:
	modified:   .gitignore
		Added binary file
2021-06-24 22:26:52 -04:00
Mike Holloway 399459c744 modified: main.go
Functions:
			hexadecimal handling
			whitespace management
			csv-like interpolation
	Next steps:
		Create map of key-value pairs using column headers
		Iterate hex conversion fucntions across values
		Track changes every 10 minutes using loop with timestamp
		Report changes to the console
2021-06-24 22:14:25 -04:00
Mike Holloway b4b01a5cf4 On branch read-file-error-check
Changes to be committed:
	new file:   main
		Perhaps add this to gitignore next time? Is it generally bad form?
	new file:   main.go
2021-06-17 01:50:06 -04:00
4 changed files with 98 additions and 0 deletions

No files matched your search

+1
View File
@@ -1 +1,2 @@
.*.sw*
main
Executable
BIN
View File
Binary file not shown.
+76
View File
@@ -0,0 +1,76 @@
package main
import (
"./timer"
"fmt"
"strings"
"regexp"
"io/ioutil"
"encoding/hex"
)
func main() {
// How to split on space-delimited fields, then colon-delimited fields?
// How to turn this byte into a string?
// /proc/net/tcp hex addresses need to be reversed two-character-wise
// and then converted byte by byte (2 char at a time)
//fmt.Println(convert_address(reverse_string(reverse_bytes("0100007F"))))
timer.New()
tcp_rows(read_tcp_file("/proc/net/tcp"))
}
func check(e error) {
if e != nil {
panic(e)
}
}
func tcp_rows(connections_file string) {
regexpression := regexp.MustCompile(`[^a-zA-Z0-9:\r\n\t\v]+`)
tcp_lines := strings.Split(connections_file, "\n")
for _, line := range tcp_lines {
trim_line := strings.TrimSpace(line)
values := regexpression.ReplaceAllString(trim_line, ",")
// Debug
// fmt.Println("New Line ==========")
fmt.Println(values)
}
}
// Take a string, create a rune slice, and use a loop to reverse it character-wise.
func reverse_bytes(s string) string {
runes := []rune(s)
for i, j := len(runes)-2, len(runes)-1; j > 0; i, j = i-2, j-2 {
runes[i], runes[j] = runes[j], runes[i]
}
return string(runes)
}
func reverse_string(s string) string {
runes := []rune(s)
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
runes[i], runes[j] = runes[j], runes[i]
}
return string(runes)
}
// Store data function
// Loads all fields and subfields into storage (memory? where?)
// State check function
// hash each line, use to determine new lines, convert to readable, and print
func convert_address(address string) []byte {
output, err := hex.DecodeString(address)
check(err)
return output
}
func read_tcp_file(connections_file_path string) string {
data, err := ioutil.ReadFile(connections_file_path)
check(err)
fmt.Println("Data file read successfully.\n")
return string(data)
}
+21
View File
@@ -0,0 +1,21 @@
package timer
import (
"fmt"
"time"
//"reflect"
)
func New() {
timer_10s := time.NewTimer(10 * time.Second)
// timer_1m := time.NewTimer(1 * time.Minute)
fmt.Println("Waiting 10 seconds...")
<-timer_10s.C
// for elapsed < ten_seconds {
//}
// for
}