Merge branch 'release-next' into issue-361

This commit is contained in:
Jeremy Tellier - ROG
2021-04-16 00:58:24 +01:00
18 changed files with 317 additions and 29 deletions
+3 -3
View File
@@ -50,6 +50,6 @@ using System.Windows;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.9.3.0")]
[assembly: AssemblyVersion("1.9.3.0")]
[assembly: AssemblyFileVersion("1.9.3.0")]
// [assembly: AssemblyVersion("1.9.4.0")]
[assembly: AssemblyVersion("1.9.4.0")]
[assembly: AssemblyFileVersion("1.9.4.0")]
+15
View File
@@ -93,6 +93,21 @@
<local:MenuEditItem x:Name="ConfigSubnet" HorizontalAlignment="Stretch" Width="Auto" Label="Subnet Mask:"></local:MenuEditItem>
<local:MenuEditItem x:Name="ConfigMtu" HorizontalAlignment="Stretch" Width="Auto" Label="MTU:"></local:MenuEditItem>
<local:MenuEditItem x:Name="ConfigDns" HorizontalAlignment="Stretch" Width="Auto" Label="DNS Servers:"></local:MenuEditItem>
<Label Content="ConfigIp" Padding="10,0,0,0" FontWeight="Bold" FontSize="12" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="Black"></Label>
<TextBox x:Name="ConfigIpNew" MaxWidth="300" Grid.Row="0" Background="Transparent" IsReadOnly="False" HorizontalAlignment="Stretch" Height="20" BorderThickness="1" TextAlignment="Left" Padding="0,0,0,0" FontSize="12" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" ></TextBox>
<Label Content="ConfigMask" Padding="10,0,0,0" FontWeight="Bold" FontSize="12" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="Black"></Label>
<TextBox x:Name="ConfigMaskNew" MaxWidth="300" Grid.Row="0" Background="Transparent" IsReadOnly="False" HorizontalAlignment="Stretch" Height="20" BorderThickness="1" TextAlignment="Left" Padding="0,0,0,0" FontSize="12" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" ></TextBox>
<Label Content="AddDns" Padding="10,0,0,0" FontWeight="Bold" FontSize="12" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="Black"></Label>
<TextBox x:Name="AddDnsNew" MaxWidth="300" Grid.Row="0" Background="Transparent" IsReadOnly="False" HorizontalAlignment="Stretch" Height="20" BorderThickness="1" TextAlignment="Left" Padding="0,0,0,0" FontSize="12" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" ></TextBox>
<Button Name="UpdateConfig" Height="40" Grid.Column="1" Margin="20,0,40,0" Width="260" Cursor="Hand" BorderThickness="0" Foreground="#FFFFFF" Background="#0069FF" Content="Update Config" Click="UpdateConfig_Click" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans">
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="5"/>
</Style>
</Button.Resources>
</Button>
</StackPanel>
<ScrollViewer Name="IdListScrollView" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" CanContentScroll="True" ClipToBounds="True" Visibility="Collapsed">
<StackPanel Name="IdListView" Orientation="Vertical" IsItemsHost="False"></StackPanel>
@@ -424,6 +424,23 @@ namespace ZitiDesktopEdge {
CheckForUpdate.IsEnabled = true;
}
async private void UpdateConfig_Click(object sender, RoutedEventArgs e) {
logger.Info("updating config...");
DataClient client = (DataClient)Application.Current.Properties["ServiceClient"];
try {
var newMaskVar = Int32.Parse(ConfigMaskNew.Text);
var addDnsNewVar = Convert.ToBoolean(AddDnsNew.Text);
var r = await client.UpdateConfigAsync(ConfigIpNew.Text, newMaskVar, addDnsNewVar);
logger.Info("Got response from update config task : {0}", r);
} catch (DataStructures.ServiceException se) {
logger.Error(se, "service exception in update check: {0}", se.Message);
}
catch (Exception ex) {
logger.Error(ex, "unexpected error in update check: {0}", ex.Message);
}
}
async private void TriggerUpdate_Click(object sender, RoutedEventArgs e) {
try {
CheckForUpdate.IsEnabled = false;
+2 -2
View File
@@ -23,10 +23,10 @@
<ROW Property="CTRLS" Value="2"/>
<ROW Property="Manufacturer" Value="NetFoundry, Inc."/>
<ROW Property="MsiLogging" MultiBuildValue="AnyCPU_Release:vp"/>
<ROW Property="ProductCode" Value="1033:{758AA10B-B1A9-45FB-97AB-20759FAB902D} " Type="16"/>
<ROW Property="ProductCode" Value="1033:{426F09F2-D144-425D-BB84-593EAA8A6CE2} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="Ziti Desktop Edge"/>
<ROW Property="ProductVersion" Value="1.9.3" Type="32"/>
<ROW Property="ProductVersion" Value="1.9.4" Type="32"/>
<ROW Property="REBOOT" MultiBuildValue="AnyCPU_Release:Suppress"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
<ROW Property="UpgradeCode" Value="{CB7E173A-663D-4A23-BB22-D1E8D885C2F3}"/>
@@ -459,4 +459,27 @@ namespace ZitiDesktopEdge.DataStructures {
public class MfaRecoveryCodesResponse : SvcResponse {
public string[] Payload { get; set; }
}
public class ConfigPayload
{
public string TunIPv4 { get; set; }
public int TunIPv4Mask { get; set; }
public bool AddDns { get; set; }
}
public class ConfigUpdateFunction : ServiceFunction
{
public ConfigUpdateFunction(string tunIPv4, int tunIPv4Mask, bool addDns)
{
this.Function = "UpdateTunIpv4";
this.Payload = new ConfigPayload()
{
TunIPv4 = tunIPv4,
TunIPv4Mask = tunIPv4Mask,
AddDns = addDns
};
}
public ConfigPayload Payload { get; set; }
}
}
@@ -390,6 +390,30 @@ namespace ZitiDesktopEdge.ServiceClient {
return;
}
async public Task<SvcResponse> UpdateConfigAsync(string tunIPv4, int tunIPv4Mask, bool addDns) {
SvcResponse resp = null;
try {
ConfigUpdateFunction configPayload = new ConfigUpdateFunction(tunIPv4, tunIPv4Mask, addDns);
await sendAsync(configPayload);
resp = await readAsync<SvcResponse>(ipcReader);
Logger.Debug("config update payload is sent to the ziti tunnel");
} catch (Exception ex) {
//almost certainly a problem with the pipe - recreate the pipe...
//setupPipe();
//throw;
Logger.Error(ex, "Unexpected error");
CommunicationError(ex);
throw ex;
}
if (resp?.Code != 0) {
Logger.Warn("failed to update the config. {0} {1}", resp.Message, resp.Error);
throw new ServiceException("Failed to update the config", resp.Code, "Un expected error.");
}
return resp;
}
async public Task<ZitiTunnelStatus> debugAsync() {
try {
await sendAsync(new ServiceFunction() { Function = "Debug" });
+3 -3
View File
@@ -30,6 +30,6 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.9.3.0")]
[assembly: AssemblyVersion("1.9.3.0")]
[assembly: AssemblyFileVersion("1.9.3.0")]
// [assembly: AssemblyVersion("1.9.4.0")]
[assembly: AssemblyVersion("1.9.4.0")]
[assembly: AssemblyFileVersion("1.9.4.0")]
+5 -7
View File
@@ -1,16 +1,13 @@
# Release 1.9.3
# Release 1.9.4
## What's New
* Page Service List
* Sort Service on Identity Details Page
* Consistent UX for MFA Screens
* none
## Other changes:
* Service to UI interaction is now with one bulk update of services instead of one event per service update
* Added a configuration option to control if DNS is applied to the TUN. Some users are having issues with NRPT-only working. For now we'll add a boolean that allows the user to control if DNS should be added to the TUN
* none
## Bugs fixed:
* none
* [#362](https://github.com/openziti/desktop-edge-win/issues/362) Update tun ip, mask and addDns flag
## Dependency Updates
* none
@@ -24,6 +21,7 @@
## Other changes:
* Service to UI interaction is now with one bulk update of services instead of one event per service update
* Added a configuration option to control if DNS is applied to the TUN. Some users are having issues with NRPT-only working. For now we'll add a boolean that allows the user to control if DNS should be added to the TUN
## Bugs fixed:
* none
+4
View File
@@ -42,6 +42,10 @@ var NOTIFY_IDENTITY_UI = dto.CommandMsg{
Function: "NotifyIdentityUI",
}
var UPDATE_TUN_IPV4 = dto.CommandMsg{
Function: "UpdateTunIpv4",
}
var monitorIpcPipe = `\\.\pipe\OpenZiti\ziti-monitor\ipc`
var templateIdentity = `{{printf "%40s" "Name"}} | {{printf "%41s" "FingerPrint"}} | {{printf "%6s" "Active"}} | {{printf "%30s" "Config"}} | {{"Status"}}
+5 -5
View File
@@ -57,11 +57,11 @@ func convertToServiceCli(svc dto.Service) dto.ServiceCli {
}
return dto.ServiceCli{
Name: svc.Name,
Id: svc.Id,
Protocols: strings.Join(svc.Protocols, ","),
Ports: cliPorts,
Addresses: cliAddresses,
Name: svc.Name,
Id: svc.Id,
Protocols: strings.Join(svc.Protocols, ","),
Ports: cliPorts,
Addresses: cliAddresses,
}
}
+57 -2
View File
@@ -1,9 +1,27 @@
package cli
import (
"strings"
/*
* Copyright NetFoundry, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import (
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/dto"
"strconv"
"strings"
"net"
)
//GetIdentities is to fetch identities through cmdline
@@ -53,3 +71,40 @@ func SetLogLevel(args []string, flags map[string]bool) {
func GetFeedback(args []string, flags map[string]bool) {
GetDataFromMonitorIpcPipe(&dto.FEEDBACK_REQUEST, args, flags)
}
func UpdateConfigIPSubnet(args []string, flags map[string]interface{}) {
CIDRstring := flags["CIDR"]
AddDns := flags["AddDns"]
log.Info("Updating the config file")
updateTunIpv4Payload := make(map[string]interface{})
if CIDRstring != "" {
ip, ipnet, err := net.ParseCIDR(CIDRstring.(string))
if err != nil {
log.Error("Incorrect cidr %s", CIDRstring.(string))
}
ipMask, _ := ipnet.Mask.Size()
updateTunIpv4Payload["TunIPv4"] = ip
updateTunIpv4Payload["TunIPv4Mask"] = ipMask
}
if AddDns != "" {
addDnsBool, err := strconv.ParseBool(AddDns.(string))
if err != nil {
log.Errorf("Incorrect addDns %v", err)
return
}
updateTunIpv4Payload["AddDns"] = addDnsBool
}
UPDATE_TUN_IPV4.Payload = updateTunIpv4Payload
log.Debugf("updateTunIpv4 Payload %v", UPDATE_TUN_IPV4)
status := GetDataFromIpcPipe(&UPDATE_TUN_IPV4, nil, GetResponseObjectFromRTS, args, nil)
if !status {
log.Infof("Config can be updated only if the tunnel is started")
}
}
+41
View File
@@ -0,0 +1,41 @@
package cmd
/*
* Copyright NetFoundry, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import (
"github.com/spf13/cobra"
)
// configCmd represents the config command
var configCmd = &cobra.Command{
Use: "config",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
checkHelp()
},
}
func init() {
rootCmd.AddCommand(configCmd)
}
+50
View File
@@ -0,0 +1,50 @@
package cmd
/*
* Copyright NetFoundry, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import (
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/cli"
"github.com/spf13/cobra"
)
var CIDR string
var AddDns string
// updateCmd represents the update command
var updateCmd = &cobra.Command{
Use: "update",
Short: "Updates data into the ziti-tunnel",
Long: `update command should be used as a sub command to the main command
It helps to update the data into the ziti-tunnel.
eg: ziti-tunnel config update --CIDR 100.64.0.1/10 --AddDns=true`,
Run: func(cmd *cobra.Command, args []string) {
flags := map[string]interface{}{}
flags["CIDR"] = CIDR
flags["AddDns"] = AddDns
cli.UpdateConfigIPSubnet(args,flags)
},
}
func init() {
configCmd.AddCommand(updateCmd)
updateCmd.Flags().StringVar(&CIDR, "CIDR", "", "Updates the cidr property in the config file")
updateCmd.Flags().StringVar(&AddDns, "AddDns", "", "Updates the Add Dns property in the config file")
}
+3 -1
View File
@@ -111,6 +111,8 @@ func main() {
commandline.Execute()
case "feedback":
commandline.Execute()
case "config":
commandline.Execute()
default:
usage(fmt.Sprintf("invalid command %s", cmd))
}
@@ -126,7 +128,7 @@ func usage(errmsg string) {
"%s\n\n"+
"usage: %s <command>\n"+
" where <command> is one of\n"+
" install, remove, debug, start, stop, pause, continue, list, identity, loglevel, feedback or version.\n",
" install, remove, debug, start, stop, pause, continue, list, identity, loglevel, feedback, config or version.\n",
errmsg, os.Args[0])
os.Exit(2)
}
+27
View File
@@ -42,6 +42,7 @@ import (
"os"
"os/signal"
"strings"
"strconv"
"sync"
"time"
)
@@ -498,6 +499,21 @@ func serveIpc(conn net.Conn) {
//save the state
rts.SaveState()
case "UpdateTunIpv4":
var tunIPv4 string
var tunIPv4Mask int
var addDns string
if cmd.Payload["TunIPv4"] != nil {
tunIPv4 = cmd.Payload["TunIPv4"].(string)
}
if cmd.Payload["TunIPv4Mask"] != nil {
var tunIpv4Mask = cmd.Payload["TunIPv4Mask"].(float64)
tunIPv4Mask = int(tunIpv4Mask)
}
if cmd.Payload["AddDns"] != nil {
addDns = strconv.FormatBool(cmd.Payload["AddDns"].(bool))
}
updateTunIpv4(enc, tunIPv4, tunIPv4Mask, addDns)
case "NotifyLogLevelUIAndUpdateService":
sendLogLevelAndNotify(enc, cmd.Payload["Level"].(string))
case "NotifyIdentityUI":
@@ -622,6 +638,17 @@ func setLogLevel(out *json.Encoder, level string) {
respond(out, dto.Response{Message: "log level set", Code: SUCCESS, Error: "", Payload: nil})
}
func updateTunIpv4(out *json.Encoder, ip string, ipMask int, addDns string) {
err := UpdateRuntimeStateIpv4(ip, ipMask, addDns)
if err != nil {
respondWithError(out, "Could not set Tun ip and mask", UNKNOWN_ERROR, err)
return
}
respond(out, dto.Response{Message: "TunIPv4 and mask is set, Manual Restart is required", Code: SUCCESS, Error: "", Payload: ""})
}
func serveLogs(conn net.Conn) {
log.Debug("accepted a logs connection, writing logs to pipe")
w := bufio.NewWriter(conn)
+33 -1
View File
@@ -29,7 +29,8 @@ import (
"path"
"strings"
"time"
"errors"
"strconv"
"github.com/openziti/desktop-edge-win/service/cziti"
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/config"
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/constants"
@@ -106,6 +107,7 @@ func backupConfig() (string, error) {
return backup, err
}
func (t *RuntimeState) ToStatus(onlyInitialized bool) dto.TunnelStatus {
var uptime int64
@@ -401,6 +403,36 @@ func (t *RuntimeState) UpdateIpv4(ipv4 string) {
rts.SaveState()
}
func UpdateRuntimeStateIpv4(ip string, ipv4Mask int, addDns string) error {
log.Infof("updating configuration ip: %s, mask: %d, dns: %t", ip, ipv4Mask, addDns)
if ipv4Mask < constants.Ipv4MaxMask || ipv4Mask > constants.Ipv4MinMask {
return errors.New(fmt.Sprintf("ipv4Mask should be between %d and %d", constants.Ipv4MaxMask, constants.Ipv4MinMask))
}
if addDns != "" {
addDnsBool, err := strconv.ParseBool(addDns)
if err != nil {
return errors.New(fmt.Sprintf("Incorrect addDns %v", err))
}
rts.state.AddDns = addDnsBool
}
// if ip is not empty, then we set both ip and mask
if ip != "" {
rts.state.TunIpv4 = ip
rts.state.TunIpv4Mask = ipv4Mask
}
rts.SaveState()
return nil
}
// uses the registry to determine if IPv6 is enabled or disabled on this machine. If it is disabled an IPv6 DNS entry
// will end up causing a fatal error on startup of the service. For this registry key and values see the MS documentation
// at https://docs.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-ipv6-in-windows
+4 -4
View File
@@ -20,9 +20,9 @@
package main
const (
Version = "1.9.3"
Revision = "a02a50cf6437"
Branch = "main"
Version = "1.9.4"
Revision = "138ceebaefbf"
Branch = "release-next"
BuildUser = ""
BuildDate = "2021-04-12 17:35:14"
BuildDate = "2021-04-15 16:07:55"
)
+1 -1
View File
@@ -1 +1 @@
1.9.3
1.9.4