Commit 8c704171 authored by 潘栩锋's avatar 潘栩锋 🚴

1. 修复 当服务地址输入域名 会出错。修改后 域名不能转为 IPv4 才会出错。

parent 73d23337
...@@ -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 Brushes.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_apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45" <Button Style="{StaticResource Styles.Button.Apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45"
Command="{Binding ApplyCmd}"/> Command="{Binding ApplyCmd}"/>
</Grid> </Grid>
</Page> </Page>
...@@ -43,7 +43,7 @@ namespace FLY.Thick.Base.UI ...@@ -43,7 +43,7 @@ namespace FLY.Thick.Base.UI
public List<ConnAddr> ConnAddrs { get; } public List<ConnAddr> ConnAddrs { get; }
public RelayCommand ApplyCmd { get; } public RelayCommand ApplyCmd { get; }
FObjServiceClientManager serviceClientManager; FObjServiceClientManager serviceClientManager;
...@@ -70,40 +70,53 @@ namespace FLY.Thick.Base.UI ...@@ -70,40 +70,53 @@ 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;
} }
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++)
{ {
//格式错误 if (!int.TryParse(m_ip.Groups[1 + i].Value, out int num))
FLY.ControlLibrary.Window_WarningTip.Show( {
"格式错误", //格式错误
$"{ca.ConnName} 地址格式错误! 第{i+1} 位IP段 出错"); FLY.ControlLibrary.Window_WarningTip.Show(
return; "格式错误",
} $"{ca.ConnName} 地址格式错误! 第{i + 1} 位IP段 出错");
if (num < 0 || num > 255) return;
{ }
//格式错误 if (num < 0 || num > 255)
FLY.ControlLibrary.Window_WarningTip.Show( {
"格式错误", //格式错误
$"{ca.ConnName} 地址格式错误! 第{i + 1}位IP段应该在 0~255 之间"); FLY.ControlLibrary.Window_WarningTip.Show(
return; "格式错误",
$"{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( 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment