diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-23 10:06:39 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-23 10:06:39 +0300 |
| commit | 9991801e4037d8dc530876584f21c1674c9e3bba (patch) | |
| tree | efa20cd6aa6556cfdea81f4c99251e0688847ca6 /pkg/messages/types/svcPrint.go | |
| parent | organize packets and classes (#9) (diff) | |
| download | sdp.go-9991801e4037d8dc530876584f21c1674c9e3bba.tar.gz sdp.go-9991801e4037d8dc530876584f21c1674c9e3bba.tar.bz2 sdp.go-9991801e4037d8dc530876584f21c1674c9e3bba.zip | |
init: will look at this laterverification
Diffstat (limited to 'pkg/messages/types/svcPrint.go')
| -rw-r--r-- | pkg/messages/types/svcPrint.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pkg/messages/types/svcPrint.go b/pkg/messages/types/svcPrint.go index 760a3c5..7b3b388 100644 --- a/pkg/messages/types/svcPrint.go +++ b/pkg/messages/types/svcPrint.go | |||
| @@ -1,10 +1,13 @@ | |||
| 1 | package messages | 1 | package messages |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | ||
| 5 | "regexp" | ||
| 6 | "strconv" | ||
| 4 | "strings" | 7 | "strings" |
| 5 | 8 | ||
| 6 | "github.com/pektezol/bitreader" | 9 | "github.com/pektezol/bitreader" |
| 7 | "github.com/pektezol/demoparser/pkg/writer" | 10 | "github.com/pektezol/demoparser/pkg/verification" |
| 8 | ) | 11 | ) |
| 9 | 12 | ||
| 10 | type SvcPrint struct { | 13 | type SvcPrint struct { |
| @@ -16,6 +19,19 @@ func ParseSvcPrint(reader *bitreader.Reader) SvcPrint { | |||
| 16 | Message: reader.TryReadString(), | 19 | Message: reader.TryReadString(), |
| 17 | } | 20 | } |
| 18 | // common psycopath behaviour | 21 | // common psycopath behaviour |
| 19 | writer.TempAppendLine("\t\t%s", strings.Replace(strings.ReplaceAll(strings.ReplaceAll(svcPrint.Message, "\n", "\n\t\t"), "\n\t\t\n\t\t", ""), "\n\t\t", "", 1)) | 22 | print := fmt.Sprintf("\t\t%s\n", strings.Replace(strings.ReplaceAll(strings.ReplaceAll(svcPrint.Message, "\n", "\n\t\t"), "\n\t\t\n\t\t", ""), "\n\t\t", "", 1)) |
| 23 | // Define a regular expression pattern to match the "Server Number" line and capture the integer value. | ||
| 24 | pattern := `Server Number: (\d+)` | ||
| 25 | |||
| 26 | // Compile the regular expression pattern. | ||
| 27 | re := regexp.MustCompile(pattern) | ||
| 28 | |||
| 29 | // Find the match in the text. | ||
| 30 | match := re.FindStringSubmatch(print) | ||
| 31 | if len(match) >= 1 { | ||
| 32 | serverNumber := match[1] | ||
| 33 | n, _ := strconv.Atoi(serverNumber) | ||
| 34 | verification.ServerNumbers = append(verification.ServerNumbers, n) | ||
| 35 | } | ||
| 20 | return svcPrint | 36 | return svcPrint |
| 21 | } | 37 | } |