Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
8c704171
Commit
8c704171
authored
Mar 21, 2022
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 修复 当服务地址输入域名 会出错。修改后 域名不能转为 IPv4 才会出错。
parent
73d23337
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
25 deletions
+47
-25
PgAddress.xaml
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgAddress.xaml
+3
-3
PgAddress.xaml.cs
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgAddress.xaml.cs
+44
-22
No files found.
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgAddress.xaml
View file @
8c704171
...
@@ -20,9 +20,9 @@
...
@@ -20,9 +20,9 @@
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="496*" />
<RowDefinition Height="496*" />
</Grid.RowDefinitions>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Background="{StaticResource Brush
_theme_bar
}" >
<StackPanel Orientation="Horizontal" Background="{StaticResource Brush
es.TitleBar.Background
}" >
<Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"/>
<Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"/>
<TextBlock Style="{StaticResource
TextBlockStyle_Title
}" Text="服务器地址"/>
<TextBlock Style="{StaticResource
Styles.TitleBar.Text
}" Text="服务器地址"/>
</StackPanel>
</StackPanel>
<DataGrid AlternationCount ="2" AlternatingRowBackground="LightGray" AutoGenerateColumns="False" CanUserAddRows="False" Margin="{StaticResource ControlMargin}"
<DataGrid AlternationCount ="2" AlternatingRowBackground="LightGray" AutoGenerateColumns="False" CanUserAddRows="False" Margin="{StaticResource ControlMargin}"
Grid.Row="1" ItemsSource="{Binding ConnAddrs}" >
Grid.Row="1" ItemsSource="{Binding ConnAddrs}" >
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
</DataGridTextColumn>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid.Columns>
</DataGrid>
</DataGrid>
<Button Style="{StaticResource
ButtonStyle_a
pply}" VerticalAlignment="Bottom" Margin="0,0,20,-45"
<Button Style="{StaticResource
Styles.Button.A
pply}" VerticalAlignment="Bottom" Margin="0,0,20,-45"
Command="{Binding ApplyCmd}"/>
Command="{Binding ApplyCmd}"/>
</Grid>
</Grid>
</Page>
</Page>
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgAddress.xaml.cs
View file @
8c704171
...
@@ -70,27 +70,36 @@ namespace FLY.Thick.Base.UI
...
@@ -70,27 +70,36 @@ namespace FLY.Thick.Base.UI
if
(!
WdPassword
.
Authorize
(
"Address"
))
if
(!
WdPassword
.
Authorize
(
"Address"
))
return
;
return
;
Regex
regex
=
new
Regex
(
@"(\d+)\.(\d+)\.(\d+)\.(\d+)\:(\d+)"
);
Regex
regex_hostname
=
new
Regex
(
@"(\S+)\:(\d+)"
);
Regex
regex_ip
=
new
Regex
(
@"(\d+)\.(\d+)\.(\d+)\.(\d+)\:(\d+)"
);
//检测地址格式
//检测地址格式
foreach
(
var
ca
in
ConnAddrs
)
foreach
(
var
ca
in
ConnAddrs
)
{
{
Match
m
=
regex
.
Match
(
ca
.
Address
);
//把地址的 : 替换为 :
if
(!
m
.
Success
)
ca
.
Address
=
ca
.
Address
.
Replace
(
":"
,
":"
);
Match
m_hostname
=
regex_hostname
.
Match
(
ca
.
Address
);
Match
m_ip
=
regex_ip
.
Match
(
ca
.
Address
);
if
(!
m_hostname
.
Success
)
{
{
//格式错误
//格式错误
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
"格式错误"
,
"格式错误"
,
$"
{
ca
.
ConnName
}
地址格式错误! 正确为 IP地址:端口号, 请检查"
);
$"
{
ca
.
ConnName
}
地址格式错误! 正确为 IP地址:端口号
或 域名:端口号
, 请检查"
);
return
;
return
;
}
}
if
(
m_ip
.
Success
)
{
//这个IP
for
(
int
i
=
0
;
i
<
4
;
i
++)
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
{
if
(!
int
.
TryParse
(
m
.
Groups
[
1
+
i
].
Value
,
out
int
num
))
if
(!
int
.
TryParse
(
m_ip
.
Groups
[
1
+
i
].
Value
,
out
int
num
))
{
{
//格式错误
//格式错误
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
"格式错误"
,
"格式错误"
,
$"
{
ca
.
ConnName
}
地址格式错误! 第
{
i
+
1
}
位IP段 出错"
);
$"
{
ca
.
ConnName
}
地址格式错误! 第
{
i
+
1
}
位IP段 出错"
);
return
;
return
;
}
}
if
(
num
<
0
||
num
>
255
)
if
(
num
<
0
||
num
>
255
)
...
@@ -102,8 +111,12 @@ namespace FLY.Thick.Base.UI
...
@@ -102,8 +111,12 @@ namespace FLY.Thick.Base.UI
return
;
return
;
}
}
}
}
}
{
{
if
(!
int
.
TryParse
(
m
.
Groups
[
5
].
Value
,
out
int
port
))
if
(!
int
.
TryParse
(
m
_hostname
.
Groups
[
2
].
Value
,
out
int
port
))
{
{
//格式错误
//格式错误
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
...
@@ -120,6 +133,15 @@ namespace FLY.Thick.Base.UI
...
@@ -120,6 +133,15 @@ namespace FLY.Thick.Base.UI
return
;
return
;
}
}
}
}
var
ep
=
Misc
.
StringConverter
.
ToIPEndPoint
(
ca
.
Address
);
if
(
ep
==
null
)
{
//不能转为ep
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
"地址出错"
,
$"
{
ca
.
ConnName
}
不能有效转换IPv4"
);
return
;
}
}
}
int
modifyCnt
=
0
;
int
modifyCnt
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment