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
Hide 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 @@
<RowDefinition Height="auto" />
<RowDefinition Height="496*" />
</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"/>
<TextBlock Style="{StaticResource
TextBlockStyle_Title
}" Text="服务器地址"/>
<TextBlock Style="{StaticResource
Styles.TitleBar.Text
}" Text="服务器地址"/>
</StackPanel>
<DataGrid AlternationCount ="2" AlternatingRowBackground="LightGray" AutoGenerateColumns="False" CanUserAddRows="False" Margin="{StaticResource ControlMargin}"
Grid.Row="1" ItemsSource="{Binding ConnAddrs}" >
...
...
@@ -52,7 +52,7 @@
</DataGridTextColumn>
</DataGrid.Columns>
</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}"/>
</Grid>
</Page>
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgAddress.xaml.cs
View file @
8c704171
...
...
@@ -43,7 +43,7 @@ namespace FLY.Thick.Base.UI
public
List
<
ConnAddr
>
ConnAddrs
{
get
;
}
public
RelayCommand
ApplyCmd
{
get
;
}
public
RelayCommand
ApplyCmd
{
get
;
}
FObjServiceClientManager
serviceClientManager
;
...
...
@@ -70,40 +70,53 @@ namespace FLY.Thick.Base.UI
if
(!
WdPassword
.
Authorize
(
"Address"
))
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
(
"格式错误"
,
$"
{
ca
.
ConnName
}
地址格式错误! 正确为 IP地址:端口号, 请检查"
);
$"
{
ca
.
ConnName
}
地址格式错误! 正确为 IP地址:端口号
或 域名:端口号
, 请检查"
);
return
;
}
for
(
int
i
=
0
;
i
<
4
;
i
++)
if
(
m_ip
.
Success
)
{
if
(!
int
.
TryParse
(
m
.
Groups
[
1
+
i
].
Value
,
out
int
num
))
//这个IP
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
//格式错误
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
"格式错误"
,
$"
{
ca
.
ConnName
}
地址格式错误! 第
{
i
+
1
}
位IP段 出错"
);
return
;
}
if
(
num
<
0
||
num
>
255
)
{
//格式错误
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
"格式错误"
,
$"
{
ca
.
ConnName
}
地址格式错误! 第
{
i
+
1
}
位IP段应该在 0~255 之间"
);
return
;
if
(!
int
.
TryParse
(
m_ip
.
Groups
[
1
+
i
].
Value
,
out
int
num
))
{
//格式错误
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
"格式错误"
,
$"
{
ca
.
ConnName
}
地址格式错误! 第
{
i
+
1
}
位IP段 出错"
);
return
;
}
if
(
num
<
0
||
num
>
255
)
{
//格式错误
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
"格式错误"
,
$"
{
ca
.
ConnName
}
地址格式错误! 第
{
i
+
1
}
位IP段应该在 0~255 之间"
);
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
(
...
...
@@ -120,6 +133,15 @@ namespace FLY.Thick.Base.UI
return
;
}
}
var
ep
=
Misc
.
StringConverter
.
ToIPEndPoint
(
ca
.
Address
);
if
(
ep
==
null
)
{
//不能转为ep
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
"地址出错"
,
$"
{
ca
.
ConnName
}
不能有效转换IPv4"
);
return
;
}
}
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