Skip to content

Commit

Permalink
Add () regex and fix x64 itemlink parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
xackery committed Feb 26, 2024
1 parent ccb2dc1 commit 48fc70b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/config_telnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Telnet struct {
IsEnabled bool `toml:"enabled" desc:"Enable Telnet"`
IsLegacy bool `toml:"legacy" desc:"EQEMU servers that run 0.8.0 versions need this set to true for item link support, everyone running any newer versions can leave it default (false)"`
LinkChunk1Size int `toml:"link_chunk1_size" desc:"Size of item links. Can leave at 0, will dynamically detect, Secrets custom is 9. but RoF2 is 6. Titanium is 6. Left for super custom servers."`
LinkChunk2Size int `toml:"link_chunk2_size" desc:"Size of item links. Can leave at 0, will dynamically detect, Secrets custom is 71. but RoF2 is 50. Titanium is 39. Left for super custom servers."`
LinkChunk2Size int `toml:"link_chunk2_size" desc:"Size of item links. Can leave at 0, will dynamically detect, Secrets custom is 68. but RoF2 is 50. Titanium is 39. Left for super custom servers."`
Host string `toml:"host" desc:"Address where telnet is found. By default, newer telnet clients will auto success on 127.0.0.1:9000"`
Username string `toml:"username" desc:"Optional. Username to connect to telnet to. (By default, newer telnet clients will auto succeed if localhost)"`
Password string `toml:"password" desc:"Optional. Password to connect to telnet to. (By default, newer telnet clients will auto succeed if localhost)"`
Expand Down
6 changes: 3 additions & 3 deletions telnet/telnet_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (

var (
// legacy item links in titanium is 6, then 39 bytes
itemLink39 = regexp.MustCompile(`\x12([0-9A-Z]{6})[0-9A-Z]{39}([\+0-9A-Za-z-'` + "`" + `:.,!?* ]+)\x12`)
itemLink39 = regexp.MustCompile(`\x12([0-9A-Z]{6})[0-9A-Z]{39}([\+()0-9A-Za-z-'` + "`" + `:.,!?* ]+)\x12`)
// rof2+ item links are 6, then 50 bytes
itemLink50 = regexp.MustCompile(`\x12([0-9A-Z]{6})[0-9A-Z]{50}([\+0-9A-Za-z-'` + "`" + `:.,!?* ]+)\x12`)
itemLink50 = regexp.MustCompile(`\x12([0-9A-Z]{6})[0-9A-Z]{50}([\+()0-9A-Za-z-'` + "`" + `:.,!?* ]+)\x12`)
// custom secrets itemlinks (64bit) are 9, then 71 bytes
itemLink71 = regexp.MustCompile(`\x12([0-9A-Z]{9})[0-9A-Z]{71}([\+0-9A-Za-z-'` + "`" + `:.,!?* ]+)\x12`)
itemLink71 = regexp.MustCompile(`\x12([0-9A-Z]{9})[0-9A-Z]{68}([\+()0-9A-Za-z-'` + "`" + `:.,!?* ]+)\x12`)
)

func (t *Telnet) convertLinks(message string) string {
Expand Down
8 changes: 6 additions & 2 deletions telnet/telnet_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ func TestConvertLinks(t *testing.T) {
messages := []test{
{
name: "mask of tinkering x64",
input: "\x1200000046F00000000000000000000000000000000000000000000000000000000000000014D2720CMask of Tinkering\x12",
output: "http://test.com?itemid=1135 (Mask of Tinkering)",
input: "\x120000027180000000000000000000000000000000000000000000000000000000000003271C223Gold Ring (Latent)\x12",
output: "http://test.com?itemid=10008 (Gold Ring (Latent))",
}, {
name: "mask of tinkering x32",
input: "\r> \b\bShin says ooc, '\x1207A50C000000000000000000000000000000000000000000CC2F1766Infused 2 Handed Damage\x12'\n",
output: "> \u0008\u0008Shin says ooc, 'http://test.com?itemid=501004 (Infused 2 Handed Damage)'",
}, {
name: "no url test",
input: `no url test`,
Expand Down

0 comments on commit 48fc70b

Please sign in to comment.