diff --git a/DesktopEdge/IdentityDetails.xaml b/DesktopEdge/IdentityDetails.xaml index eeb2d905..11aafaba 100644 --- a/DesktopEdge/IdentityDetails.xaml +++ b/DesktopEdge/IdentityDetails.xaml @@ -51,5 +51,38 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DesktopEdge/IdentityDetails.xaml.cs b/DesktopEdge/IdentityDetails.xaml.cs index fc47e1b0..403fb727 100644 --- a/DesktopEdge/IdentityDetails.xaml.cs +++ b/DesktopEdge/IdentityDetails.xaml.cs @@ -99,35 +99,37 @@ namespace ZitiDesktopEdge { MainDetailScroll.Height = height; } - private void ForgetIdentity(object sender, MouseButtonEventArgs e) { - // Jeremy - this works now as long as you pass a fingerprint that's valid! - UIModel.HideOnLostFocus = false; - MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to forget this identity?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); - UIModel.HideOnLostFocus = true; - if (messageBoxResult == MessageBoxResult.Yes) { - this.Visibility = Visibility.Collapsed; - ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"]; - try { - client.RemoveIdentity(_identity.Fingerprint); + private void CancelConfirm(object sender, MouseButtonEventArgs e) { + ConfirmView.Visibility = Visibility.Collapsed; + } - ZitiIdentity forgotten = new ZitiIdentity(); - foreach (var id in identities) { - if (id.Fingerprint == _identity.Fingerprint) { - forgotten = id; - identities.Remove(id); - break; - } - } + private void ConfirmForget(object sender, MouseButtonEventArgs e) { + this.Visibility = Visibility.Collapsed; + ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"]; + try { + client.RemoveIdentity(_identity.Fingerprint); - if (OnForgot != null) { - OnForgot(forgotten); + ZitiIdentity forgotten = new ZitiIdentity(); + foreach (var id in identities) { + if (id.Fingerprint == _identity.Fingerprint) { + forgotten = id; + identities.Remove(id); + break; } - } catch (ServiceClient.ServiceException se) { - OnError(se.Message); - } catch (Exception ex) { - OnError(ex.Message); } + + if (OnForgot != null) { + OnForgot(forgotten); + } + } catch (ServiceClient.ServiceException se) { + OnError(se.Message); + } catch (Exception ex) { + OnError(ex.Message); } } + + private void ForgetIdentity(object sender, MouseButtonEventArgs e) { + ConfirmView.Visibility = Visibility.Visible; + } } } diff --git a/DesktopEdge/MainMenu.xaml.cs b/DesktopEdge/MainMenu.xaml.cs index feec6188..f35ae09b 100644 --- a/DesktopEdge/MainMenu.xaml.cs +++ b/DesktopEdge/MainMenu.xaml.cs @@ -140,12 +140,13 @@ namespace ZitiDesktopEdge mailMessage.IsBodyHtml = true; mailMessage.Body = ""; - string serviceLogTempFile = Path.Combine(Path.GetTempPath(), "Ziti-Service.log"); + string timestamp = DateTime.Now.ToFileTime().ToString(); + string serviceLogTempFile = Path.Combine(Path.GetTempPath(), timestamp+"-Ziti-Service.log"); using (StreamWriter sw = new StreamWriter(serviceLogTempFile)) { sw.WriteLine(client.GetLogs()); } - string uiLogTempFile = Path.Combine(Path.GetTempPath(), "Ziti-Application.log"); + string uiLogTempFile = Path.Combine(Path.GetTempPath(), timestamp+"-Ziti-Application.log"); using (StreamWriter sw = new StreamWriter(uiLogTempFile)) { sw.WriteLine(UILog.GetLogs()); } @@ -153,7 +154,7 @@ namespace ZitiDesktopEdge mailMessage.Attachments.Add(new Attachment(serviceLogTempFile)); mailMessage.Attachments.Add(new Attachment(uiLogTempFile)); - string emlFile = Path.Combine(Path.GetTempPath(), "ziti.eml"); + string emlFile = Path.Combine(Path.GetTempPath(), timestamp+"-ziti.eml"); using (var filestream = File.Open(emlFile, FileMode.Create)) { var binaryWriter = new BinaryWriter(filestream); diff --git a/DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml b/DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml index 1fe5b1dd..c6a7806c 100644 --- a/DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml +++ b/DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml @@ -14,8 +14,8 @@ - - + + diff --git a/service/build.bat b/service/build.bat index 5120c060..25a97902 100644 --- a/service/build.bat +++ b/service/build.bat @@ -8,14 +8,18 @@ cd /d %ZITI_TUNNEL_WIN_ROOT% IF "%BUILD_VERSION%"=="" GOTO BUILD_VERSION_ERROR IF "%1"=="clean" GOTO CLEAN -IF "%1"=="quick" GOTO QUICK +IF "%1"=="quick" ( + echo doing 'quick' build - no tunneler sdk/c sdk build + GOTO QUICK +) echo fetching ziti-ci call %SVC_ROOT_DIR%/../get-ziti-ci.bat +echo ziti-ci has been retrieved. running: ziti-ci version ziti-ci version -echo generating version info - this will pushed from publish.bat in CI -ziti-ci generate-build-info --noAddNoCommit --useVersion=false %SVC_ROOT_DIR%/ziti-tunnel/version.go main --verbose +echo generating version info - this will get pushed from publish.bat in CI _if_ publish.bat started build.bat +ziti-ci generate-build-info --noAddNoCommit --useVersion=false %SVC_ROOT_DIR%/ziti-tunnel/version.go main --verbose 2>&1 echo version info generated goto QUICK @@ -24,13 +28,14 @@ rmdir /s /q deps del /q %SVC_ROOT_DIR%ziti.dll :QUICK +echo changing to service folder: %SVC_ROOT_DIR% cd %SVC_ROOT_DIR% SET REPO_URL=https://github.com/openziti/ziti-tunneler-sdk-c.git SET ZITI_TUNNEL_REPO_BRANCH=master SET TUNNELER_SDK_DIR=%SVC_ROOT_DIR%deps\ziti-tunneler-sdk-c\ -set CGO_CFLAGS=-DNOGDI -I %TUNNELER_SDK_DIR%install\include -set CGO_LDFLAGS=-L %TUNNELER_SDK_DIR%install\lib +SET CGO_CFLAGS=-DNOGDI -I %TUNNELER_SDK_DIR%install\include +SET CGO_LDFLAGS=-L %TUNNELER_SDK_DIR%install\lib if exist %SVC_ROOT_DIR%ziti.dll ( echo ------------------------------------------------------------------------------ @@ -46,6 +51,8 @@ echo --------------------------------------------------------------------------- set BEFORE_GIT=%cd% if exist %TUNNELER_SDK_DIR% ( + echo %TUNNELER_SDK_DIR% exists + cd %TUNNELER_SDK_DIR% echo ------------------------------------------------------------------------------ echo issuing git pull to pick up any changes echo ------------------------------------------------------------------------------ @@ -55,7 +62,8 @@ if exist %TUNNELER_SDK_DIR% ( echo ------------------------------------------------------------------------------ ) else ( echo ------------------------------------------------------------------------------ - echo cloning %REPO_URL% + echo %TUNNELER_SDK_DIR% not found + echo - cloning %REPO_URL% echo ------------------------------------------------------------------------------ echo issuing mkdir %TUNNELER_SDK_DIR% mkdir %TUNNELER_SDK_DIR% @@ -64,6 +72,10 @@ if exist %TUNNELER_SDK_DIR% ( cd %TUNNELER_SDK_DIR% echo current directory is %CD% - should be %TUNNELER_SDK_DIR% + echo. + echo git clone %REPO_URL% %TUNNELER_SDK_DIR% --recurse-submodules + echo. + git clone %REPO_URL% %TUNNELER_SDK_DIR% --recurse-submodules SET ACTUAL_ERR=%ERRORLEVEL% ) @@ -75,6 +87,8 @@ IF %ACTUAL_ERR% NEQ 0 ( ) echo checking out branch: %ZITI_TUNNEL_REPO_BRANCH% + +echo in %cd% - checking out branch: %ZITI_TUNNEL_REPO_BRANCH% git checkout %ZITI_TUNNEL_REPO_BRANCH% IF %ERRORLEVEL% NEQ 0 ( SET ACTUAL_ERR=%ERRORLEVEL% @@ -84,6 +98,8 @@ IF %ERRORLEVEL% NEQ 0 ( goto FAIL ) +echo "clone or checkout complete." + echo ------------------------------------------------------------------------------ type %TUNNELER_SDK_DIR%.gitmodules echo. diff --git a/service/cziti/ctun.go b/service/cziti/ctun.go index eb3db76d..2e1e088f 100644 --- a/service/cziti/ctun.go +++ b/service/cziti/ctun.go @@ -150,13 +150,13 @@ func netifSetup(h C.netif_handle, l *C.uv_loop_t, packetCb C.packet_cb, ctx unsa t.read = (*C.uv_async_t)(C.calloc(1, C.sizeof_uv_async_t)) C.uv_async_init(l, t.read, C.uv_async_cb(C.readAsync)) t.read.data = unsafe.Pointer(h) - log.Debugf("in netifSetup netif[%s] handle[%p]", C.GoString(h.id), h) + log.Debugf("in netifSetup netif[%s] handle[%p] before", C.GoString(h.id), h) t.idleR = (*C.uv_prepare_t)(C.calloc(1, C.sizeof_uv_prepare_t)) C.uv_prepare_init(l, t.idleR) t.idleR.data = unsafe.Pointer(h) C.uv_prepare_start(t.idleR, C.uv_prepare_cb(C.readIdle)) - log.Debugf("in netifSetup netif[%s] handle[%p]", C.GoString(h.id), h) + log.Debugf("in netifSetup netif[%s] handle[%p] after", C.GoString(h.id), h) t.onPacket = packetCb t.onPacketCtx = ctx diff --git a/service/cziti/dns-proxy.go b/service/cziti/dns-proxy.go index 4c67a038..4d63c489 100644 --- a/service/cziti/dns-proxy.go +++ b/service/cziti/dns-proxy.go @@ -20,7 +20,10 @@ package cziti import ( "fmt" "github.com/miekg/dns" + "io" "net" + "os" + "strings" "time" "github.com/openziti/desktop-edge-win/service/cziti/windns" ) @@ -155,16 +158,16 @@ func proxyDNS(req *dns.Msg, peer *net.UDPAddr, serv *net.UDPConn) { } } -func dnsPanicRecover(dnsServers []string) { - //just rerun the dns proxy function - go runDNSproxy(dnsServers) +func dnsPanicRecover() { + // get dns again and reconfigure + go runDNSproxy(windns.GetUpstreamDNS()) } func runDNSproxy(dnsServers []string) { defer func() { if r := recover(); r != nil { log.Errorf("Recovered in f. %v", r) - dnsPanicRecover(dnsServers) + dnsPanicRecover() } }() @@ -172,7 +175,13 @@ func runDNSproxy(dnsServers []string) { for _, s := range dnsServers { sAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:53", s)) if err != nil { - log.Debugf("skipping upstream: %s, %v", s, err.Error()) + // fec0:0:0:ffff:: is 'legacy' from windows apparently... + // see: https://en.wikipedia.org/wiki/IPv6_address#Deprecated_and_obsolete_addresses_2 + if ! strings.HasPrefix(s, "fec0:0:0:ffff::") { + log.Debugf("skipping upstream: %s, %v", s, err.Error()) + } else { + // just ignore for now - don't even log it... + } } else { log.Debugf("adding upstream dns server: %s", s) conn, err := net.DialUDP("udp", nil, sAddr) @@ -193,7 +202,12 @@ func runDNSproxy(dnsServers []string) { for { n, err := proxy.Read(resp) if err != nil { - log.Debug("error receiving from ", proxy.RemoteAddr(), err) + // something is wrong with the DNS connection panic and let DNS recovery kick in + if err == io.EOF || err == os.ErrClosed || err.Error() == "use of closed network connection" { + log.Panicf("error receiving from ", proxy.RemoteAddr(), err) + } else { + log.Panicf("UNEXPECTED error receiving from ", proxy.RemoteAddr(), err) + } } else { respChan <- resp[:n] } diff --git a/service/cziti/sdk.go b/service/cziti/sdk.go index 83e1f822..c0fcc824 100644 --- a/service/cziti/sdk.go +++ b/service/cziti/sdk.go @@ -200,6 +200,8 @@ func serviceCB(_ C.ziti_context, service *C.ziti_service, status C.int, data uns Service: &added, ZitiContext: ctx, } + } else { + log.Debugf("service named %s is not enabled for 'tunneling'", name) } } } diff --git a/service/publish.bat b/service/publish.bat index 72743dd9..58aa5c19 100644 --- a/service/publish.bat +++ b/service/publish.bat @@ -8,24 +8,24 @@ IF "%BUILD_VERSION%"=="" GOTO BUILD_VERSION_ERROR call %SVC_ROOT_DIR%\build.bat SET ACTUAL_ERR=%ERRORLEVEL% if %ACTUAL_ERR% NEQ 0 ( - echo. - echo call to build.bat failed with %ACTUAL_ERR% - echo. + @echo. + @echo call to build.bat failed with %ACTUAL_ERR% + @echo. exit /b 1 ) else ( - echo. - echo result of ninja build: %ACTUAL_ERR% + @echo. + @echo result of ninja build: %ACTUAL_ERR% ) IF "%GIT_BRANCH%"=="master" GOTO RELEASE @echo Publishing to snapshot repo -ziti-ci publish artifactory --groupId=ziti-tunnel-win.amd64.windows --artifactId=ziti-tunnel-win --version=%BUILD_VERSION%-SNAPSHOT --target=service/ziti-tunnel-win.zip -REM ziti-ci publish artifactory --groupId=ziti-tunnel-win.amd64.windows --artifactId=ziti-tunnel-win --version=%BUILD_VERSION%-SNAPSHOT --target=service/ziti-tunnel-win.zip --classifier=%GIT_BRANCH% +ziti-ci publish artifactory --groupId=ziti-tunnel-win.amd64.windows --artifactId=ziti-tunnel-win --version=%BUILD_VERSION%-SNAPSHOT --target=service/ziti-tunnel-win.zip 2>&1 +REM ziti-ci publish artifactory --groupId=ziti-tunnel-win.amd64.windows --artifactId=ziti-tunnel-win --version=%BUILD_VERSION%-SNAPSHOT --target=service/ziti-tunnel-win.zip --classifier=%GIT_BRANCH% 2>&1 GOTO END :RELEASE @echo Publishing release -ziti-ci publish artifactory --groupId=ziti-tunnel-win.amd64.windows --artifactId=ziti-tunnel-win --version=%BUILD_VERSION% --target=service/ziti-tunnel-win.zip +ziti-ci publish artifactory --groupId=ziti-tunnel-win.amd64.windows --artifactId=ziti-tunnel-win --version=%BUILD_VERSION% --target=service/ziti-tunnel-win.zip 2>&1 GOTO END :BUILD_VERSION_ERROR @@ -34,45 +34,57 @@ exit /b 1 :FAIL IF %~1 NEQ 0 ( - echo ================================================================ - echo. - echo FAILURE: - echo %~2 - echo. - echo ================================================================ + @echo ================================================================ + @echo. + @echo FAILURE: + @echo %~2 + @echo. + @echo ================================================================ exit /b %~1 ) exit /b 0 :END -echo configuring git - relies on build.bat successfully grabbing ziti-ci and build.bat updating service/ziti-tunnel/version.go -ziti-ci configure-git 2>&1 @echo publishing complete - committing version.go as ci +@echo changing back to: %CURDIR% +cd %CURDIR% +@echo current dir: %CD% +@echo configuring git - relies on build.bat successfully grabbing ziti-ci and build.bat updating service/ziti-tunnel/version.go +ziti-ci configure-git 2>&1 + +@echo converting shallow clone so travis can co: %GIT_BRANCH% +git remote set-branches origin %GIT_BRANCH% 2>&1 +git fetch --depth 1 origin %GIT_BRANCH% 2>&1 git checkout %GIT_BRANCH% 2>&1 CALL :FAIL %ERRORLEVEL% "checkout failed" - @echo git checkout %GIT_BRANCH% complete: %ERRORLEVEL% +@echo issuing status +@echo ======================================================== +git status 2>&1 + git add service/ziti-tunnel/version.go 2>&1 CALL :FAIL %ERRORLEVEL% "git add failed" @echo git add service/ziti-tunnel/version.go complete: %ERRORLEVEL% -@echo issuing status, diff, commit -@echo ======================================================== -git status 2>&1 -git diff 2>&1 +@echo issuing ssh -vT -i github_deploy_key git@github.com +ssh-keyscan -H github.com >> ~/.ssh/known_hosts +ssh -vT -i github_deploy_key git@github.com 2>&1 + +@echo issuing commit git commit -m "[ci skip] committing updated version information" 2>&1 CALL :FAIL %ERRORLEVEL% "git commit failed" @echo git commit -m "[ci skip] committing updated version information" complete: %ERRORLEVEL% - -@echo issuing git status and push now @echo ======================================================== -git status 2>&1 -git push 2>&1 +@echo issuing git push +@echo ======================================================== +@echo setting git config remote.url git@github.com:openziti/desktop-edge-win.git +git config remote.url git@github.com:openziti/desktop-edge-win.git 2>&1 +git config --list 2>&1 +dir github_deploy_key +git push --verbose 2>&1 CALL :FAIL %ERRORLEVEL% "git push failed" @echo git push complete: %ERRORLEVEL% - -cd %CURDIR% @echo publish script has completed diff --git a/service/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go index c55c5eff..bbe122f0 100644 --- a/service/ziti-tunnel/service/ipc.go +++ b/service/ziti-tunnel/service/ipc.go @@ -259,12 +259,12 @@ func setTunInfo(s *dto.TunnelStatus, ipv4 string, ipv4mask int) { log.Errorf("error reading MTU - using 0 for MTU: (%v)", err) mtu = 0 } - + umtu := uint16(mtu) //set the tun info into the state s.IpInfo = &dto.TunIpInfo{ Ip: ipv4, DNS: Ipv4dns, - MTU: uint16(mtu), + MTU: umtu, Subnet: ipv4MaskString(ipnet.Mask), } } diff --git a/service/ziti-tunnel/service/state.go b/service/ziti-tunnel/service/state.go index 4e86942c..a46b9ea2 100644 --- a/service/ziti-tunnel/service/state.go +++ b/service/ziti-tunnel/service/state.go @@ -120,7 +120,7 @@ func (t *RuntimeState) CreateTun(ipv4 string, ipv4mask int) error { } log.Infof("creating TUN device: %s", TunName) - tunDevice, err := tun.CreateTUN(TunName, 64*1024) + tunDevice, err := tun.CreateTUN(TunName, 64*1024 - 1) if err == nil { t.tun = &tunDevice tunName, err2 := tunDevice.Name() diff --git a/testing.txt b/testing.txt new file mode 100644 index 00000000..45b983be --- /dev/null +++ b/testing.txt @@ -0,0 +1 @@ +hi