Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Use struct Int32Range widely #3867

Merged
merged 8 commits into from
Oct 15, 2024
Merged

Refactor: Use struct Int32Range widely #3867

merged 8 commits into from
Oct 15, 2024

Conversation

Fangliding
Copy link
Member

#3855 (comment)
Why not?

@Fangliding
Copy link
Member Author

noises已经用了 其他的好像没看到浮动值

@RPRX
Copy link
Member

RPRX commented Oct 2, 2024

第一时间还想到了 port range,还有 SpiderX 也能换上,不过它不是 JSON

@Fangliding
Copy link
Member Author

Fangliding commented Oct 2, 2024

第一时间还想到了 port range,还有 SpiderX 也能换上,不过它不是 JSON

port range并不是纯范围,它更像是一个带语法糖的数组 (1,2,3-5,8 这样)

@RPRX
Copy link
Member

RPRX commented Oct 2, 2024

好的,你再过一遍文档看看哪里还有 IntRange 吧,一并改用它

@Fangliding
Copy link
Member Author

看完了才来的 应该没了 吧

@RPRX
Copy link
Member

RPRX commented Oct 2, 2024

那先放一段时间看看有没有其他人提

@Fangliding
Copy link
Member Author

那先放一段时间看看有没有其他人提

strings.Split() 这个函数看了一下调用大概是没其他地方了

@RPRX
Copy link
Member

RPRX commented Oct 3, 2024

EnsureOrder() 的功能应该放 UnmarshalJSON() 里自动调用

@Fangliding
Copy link
Member Author

EnsureOrder() 的功能应该放 UnmarshalJSON() 里自动调用

我不确定需不需要 因为可能不知道啥时候从大到小的范围可能会有意义

@RPRX
Copy link
Member

RPRX commented Oct 3, 2024

EnsureOrder() 的功能应该放 UnmarshalJSON() 里自动调用

我不确定需不需要 因为可能不知道啥时候从大到小的范围可能会有意义

加上,再给 type Int32Range struct 加个 Re bool,默认 false,原始输入是从大到小就设为 true

@RPRX
Copy link
Member

RPRX commented Oct 3, 2024

还有含负数的也写个解析吧,就基本不用再改了

@Fangliding
Copy link
Member Author

Fangliding commented Oct 3, 2024

EnsureOrder() 的功能应该放 UnmarshalJSON() 里自动调用

我不确定需不需要 因为可能不知道啥时候从大到小的范围可能会有意义

加上,再给 type Int32Range struct 加个 Re bool,默认 false,原始输入是从大到小就设为 true

搞个OriginFrom和OriginTo可能好一点点

负数的话 1--2还是感觉有点诡异

@RPRX
Copy link
Member

RPRX commented Oct 3, 2024

搞个OriginFrom和OriginTo可能好一点点

感觉有点不优雅

负数的话 1--2还是感觉有点诡异

逻辑很简单,第一个负号出现在开头就找第二个负号为分割符然后常规解析,没有第二个负号就是单独负数

@Fangliding
Copy link
Member Author

Fangliding commented Oct 3, 2024

搞个OriginFrom和OriginTo可能好一点点

感觉有点不优雅

写个bool等真要用再写个if交换更奇怪

逻辑很简单,第一个负号出现在开头就找第二个负号为分割符然后常规解析,没有第二个负号就是单独负数

不是实现方法的问题 是这个写法本身就诡异(虽然逻辑上没问题)

@RPRX
Copy link
Member

RPRX commented Oct 4, 2024

这样吧

  • From
  • To
  • Left
  • Right

把现有的那些都改为 Left 和 Right

@Fangliding
Copy link
Member Author

这样吧

  • From
  • To
  • Left
  • Right

把现有的那些都改为 Left 和 Right

还是
From To 正常交换
Left Right 原始
吧 就不break了

@RPRX
Copy link
Member

RPRX commented Oct 4, 2024

Left Right 原始

其实我本来想的是数轴,不过被你这么一说

那就 Left Right 代表原始,放 From To 上面,还有加上包含负数的解析

@RPRX
Copy link
Member

RPRX commented Oct 5, 2024

那就 Left Right 代表原始,放 From To 上面,还有加上包含负数的解析

@Fangliding 该写代码了

@RPRX
Copy link
Member

RPRX commented Oct 5, 2024

发现文档 noise: array UDP noise 少了 s,还有 Int32Range “独立的int” 似乎标错了地方 @Fangliding

@RPRX
Copy link
Member

RPRX commented Oct 5, 2024

根据含义应当把 Left Right 放结构体的开头,并且先操作它们,最后再对 From To 赋值

@RPRX
Copy link
Member

RPRX commented Oct 5, 2024

还有包含负数的解析

@RPRX
Copy link
Member

RPRX commented Oct 5, 2024

// "-114-514" → ["114","-514"]

@Fangliding
Copy link
Member Author

确实疑惑 搞得我都看错了

@RPRX
Copy link
Member

RPRX commented Oct 5, 2024

把逻辑抽出来,这样 packets 也能用

还有现有这些地方都要检查下 From 不小于 0,我还在想加哪合适

@RPRX
Copy link
Member

RPRX commented Oct 5, 2024

这样 packets 也能用

还有 SpiderX,别的应该没了

@Fangliding
Copy link
Member Author

差不多了吧 spiderx我不知道它是怎么干活的(连个文档都无)

@RPRX
Copy link
Member

RPRX commented Oct 5, 2024

啊这,其实我指的是 fragment 的 packets,不过 noise 那里的确也要改

@RPRX
Copy link
Member

RPRX commented Oct 8, 2024

我看到新的代码用了 uint64,但自动 unmarshal 那里并没有,有丶割裂,any advice?

@Fangliding
Copy link
Member Author

Fangliding commented Oct 8, 2024

我看到新的代码用了 uint64,但自动 unmarshal 那里并没有,有丶割裂,any advice?

老的ParseUint就指定了64 当然不需要啊

这个类型就叫 int32range 输出肯定是个int32 转换一下肯定的

我个人一直是非必要不用奇奇怪怪的整型 现在再改又break proto然后还得把出站里代码掀了改掉 早提该在合的时候就提的 不过加个小函数修改类型完全是可以接受的

@RPRX
Copy link
Member

RPRX commented Oct 15, 2024

打算先合了,不久后会把那些 proto 都改为 uint64

@RPRX RPRX changed the title 使用Int32Range类型解析Fragment Refactor: Use struct Int32Range widely Oct 15, 2024
@RPRX RPRX merged commit b4608ef into main Oct 15, 2024
36 checks passed
@RPRX
Copy link
Member

RPRX commented Oct 15, 2024

忘加 comment 了,我重来

RPRX pushed a commit that referenced this pull request Oct 15, 2024
leninalive pushed a commit to amnezia-vpn/amnezia-xray-core that referenced this pull request Oct 29, 2024
@yuhan6665 yuhan6665 deleted the Int32Range-in-Fragment branch November 4, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants