mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-13 16:21:25 +00:00
Merge branch 'master' of github.com:openziti/ziti-tunnel-win
This commit is contained in:
@@ -40,6 +40,7 @@ namespace ZitiTunneler {
|
||||
}
|
||||
set {
|
||||
_identity = value;
|
||||
this.IdDetailToggle.Enabled = _identity.IsEnabled;
|
||||
UpdateView();
|
||||
IdentityArea.Opacity = 1.0;
|
||||
IdentityArea.Visibility = Visibility.Visible;
|
||||
@@ -47,6 +48,9 @@ namespace ZitiTunneler {
|
||||
}
|
||||
}
|
||||
|
||||
public IdentityItem SelectedIdentity { get; set; }
|
||||
|
||||
|
||||
public bool IsAttached {
|
||||
get {
|
||||
return _isAttached;
|
||||
@@ -63,8 +67,8 @@ namespace ZitiTunneler {
|
||||
IdDetailToggle.Enabled = _identity.IsEnabled;
|
||||
IdentityName.Value = _identity.Name;
|
||||
IdentityNetwork.Value = _identity.ControllerUrl;
|
||||
IdentityEnrollment.Value = _identity.EnrollmentStatus;
|
||||
IdentityStatus.Value = _identity.Status;
|
||||
IdentityEnrollment.Value = _identity.Status;
|
||||
IdentityStatus.Value = _identity.IsEnabled ? "active" : "disabled";
|
||||
ServiceList.Children.Clear();
|
||||
for (int i=0; i<_identity.Services.Count; i++) {
|
||||
ServiceInfo editor = new ServiceInfo();
|
||||
@@ -78,6 +82,9 @@ namespace ZitiTunneler {
|
||||
private void IdToggle(bool on) {
|
||||
ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"];
|
||||
client.IdentityOnOff(_identity.Fingerprint, on);
|
||||
SelectedIdentity.ToggleSwitch.Enabled = on;
|
||||
_identity.IsEnabled = on;
|
||||
IdentityStatus.Value = _identity.IsEnabled ? "active" : "disabled";
|
||||
}
|
||||
|
||||
public IdentityDetails() {
|
||||
|
||||
@@ -20,8 +20,6 @@ namespace ZitiTunneler {
|
||||
/// </summary>
|
||||
public partial class IdentityItem:UserControl {
|
||||
|
||||
public delegate void Click(ZitiIdentity identity);
|
||||
public event Click OnClick;
|
||||
public ZitiIdentity _identity;
|
||||
public ZitiIdentity Identity {
|
||||
get {
|
||||
@@ -45,7 +43,6 @@ namespace ZitiTunneler {
|
||||
}
|
||||
}
|
||||
|
||||
public bool isOn = false;
|
||||
public IdentityItem() {
|
||||
InitializeComponent();
|
||||
ToggleSwitch.OnToggled += ToggleIdentity;
|
||||
@@ -72,10 +69,6 @@ namespace ZitiTunneler {
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleButton_Checked(object sender, RoutedEventArgs e) {
|
||||
isOn = !isOn;
|
||||
}
|
||||
|
||||
private void Canvas_MouseEnter(object sender, MouseEventArgs e) {
|
||||
OverState.Opacity = 0.2;
|
||||
}
|
||||
@@ -85,9 +78,10 @@ namespace ZitiTunneler {
|
||||
}
|
||||
|
||||
private void OpenDetails(object sender, MouseButtonEventArgs e) {
|
||||
if (OnClick != null) {
|
||||
OnClick(_identity);
|
||||
}
|
||||
IdentityDetails deets = ((MainWindow)Application.Current.MainWindow).IdentityMenu;
|
||||
deets.SelectedIdentity = this;
|
||||
deets.Identity = this.Identity;
|
||||
this.ToggleSwitch.IsEnabled = this.Identity.IsEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,10 @@ namespace ZitiTunneler {
|
||||
var found = identities.Find(i => i.Fingerprint == e.Id.FingerPrint);
|
||||
if (found == null) {
|
||||
identities.Add(zid);
|
||||
} else {
|
||||
//if we get here exit out so that LoadIdentities() doesn't get called
|
||||
found.IsEnabled = true;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
IdentityForgotten(ZitiIdentity.FromClient(e.Id));
|
||||
@@ -334,7 +338,7 @@ namespace ZitiTunneler {
|
||||
DisconnectButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
id.Identity = ids[i];
|
||||
id.OnClick += OpenIdentity;
|
||||
//id.OnClick += OpenIdentity;
|
||||
IdList.Children.Add(id);
|
||||
IdList.Height += 60;
|
||||
}
|
||||
@@ -345,7 +349,7 @@ namespace ZitiTunneler {
|
||||
|
||||
private void OpenIdentity(ZitiIdentity identity) {
|
||||
IdentityMenu.Identity = identity;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void ShowMenu(object sender, MouseButtonEventArgs e) {
|
||||
@@ -401,7 +405,7 @@ namespace ZitiTunneler {
|
||||
_timer.Enabled = true;
|
||||
_timer.Start();
|
||||
}
|
||||
private async void Connect(object sender, RoutedEventArgs e)
|
||||
private void Connect(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
@@ -424,7 +428,6 @@ namespace ZitiTunneler {
|
||||
}
|
||||
for (int i = 0; i < IdList.Children.Count; i++) {
|
||||
IdentityItem item = IdList.Children[i] as IdentityItem;
|
||||
item.isOn = true;
|
||||
item._identity.IsEnabled = true;
|
||||
item.RefreshUI();
|
||||
}
|
||||
@@ -448,7 +451,6 @@ namespace ZitiTunneler {
|
||||
}
|
||||
for (int i = 0; i < IdList.Children.Count; i++) {
|
||||
IdentityItem item = IdList.Children[i] as IdentityItem;
|
||||
item.isOn = false;
|
||||
item._identity.IsEnabled = false;
|
||||
item.RefreshUI();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.IO;
|
||||
|
||||
namespace ZitiTunneler.Models {
|
||||
|
||||
@@ -249,7 +249,7 @@ func (t *tunnel) runWriteLoop() {
|
||||
func (t *tunnel) AddIntercept(svcId string, service string, host string, port int, ctx unsafe.Pointer) {
|
||||
log.Debugf("about to add intercept for: %s, %s, %d", service, host, port)
|
||||
res := C.ziti_tunneler_intercept_v1(t.tunCtx, ctx, C.CString(svcId), C.CString(service), C.CString(host), C.int(port))
|
||||
log.Debugf("intercept added", res)
|
||||
log.Debugf("intercept added: %v", res)
|
||||
}
|
||||
|
||||
func RemoveIntercept(svcvId string) {
|
||||
@@ -263,6 +263,6 @@ func AddIntercept(svcId string, service string, host string, port uint16, ctx *C
|
||||
for _, t := range devMap {
|
||||
log.Debug("adding intercept for: %s, %s, %d", service, host, port)
|
||||
res := C.ziti_tunneler_intercept_v1(t.tunCtx, unsafe.Pointer(ctx.nf), C.CString(svcId), C.CString(service), C.CString(host), C.int(port))
|
||||
log.Debugf("intercept added", res)
|
||||
log.Debugf("intercept added: %v", res)
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func processDNSquery(packet []byte, p *net.UDPAddr, s *net.UDPConn) {
|
||||
|
||||
// never proxy hostnames that we know about regardless of type
|
||||
if ip != nil {
|
||||
log.Debug("resolved ", query.Name, ip)
|
||||
log.Debugf("resolved %s as %v", query.Name, ip)
|
||||
|
||||
var answer *dns.A
|
||||
if query.Qtype == dns.TypeA && len(ip.To4()) == net.IPv4len {
|
||||
|
||||
@@ -58,6 +58,7 @@ type ctxService struct {
|
||||
}
|
||||
|
||||
func (dns *dnsImpl) RegisterService(dnsName string, port uint16, ctx *CZitiCtx, name string) (net.IP, error) {
|
||||
log.Infof("adding DNS entry for service name %s@%s:%d", name, dnsName, port)
|
||||
DnsInit(defaultCidr, defaultMaskBits)
|
||||
dnsName = dnsName + "."
|
||||
key := fmt.Sprint(dnsName, ':', port)
|
||||
|
||||
@@ -172,11 +172,11 @@ func serviceCB(nf C.ziti_context, service *C.ziti_service, status C.int, data un
|
||||
}
|
||||
ctx.Services.Store(id, added)
|
||||
if host != "" && port != -1 {
|
||||
log.Infof("service intercept beginning for service: %s @ %s:%d")
|
||||
ip, err := DNS.RegisterService(host, uint16(port), ctx, name)
|
||||
if err != nil {
|
||||
log.Warn(err)
|
||||
} else {
|
||||
log.Infof("service intercept beginning for service: %s@%s:%d on ip %s", name, host, port, ip.String())
|
||||
log.Infof("service[%s] is mapped to <%s:%d>", name, ip.String(), port)
|
||||
for _, t := range devMap {
|
||||
t.AddIntercept(id, name, ip.String(), port, unsafe.Pointer(ctx.nf))
|
||||
|
||||
@@ -42,7 +42,7 @@ func ResetDNS() {
|
||||
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Errorf("ERROR resetting DNS", err)
|
||||
log.Errorf("ERROR resetting DNS: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/Microsoft/go-winio"
|
||||
"github.com/netfoundry/ziti-foundation/identity/identity"
|
||||
idcfg "github.com/netfoundry/ziti-sdk-golang/ziti/config"
|
||||
"github.com/netfoundry/ziti-sdk-golang/ziti/enroll"
|
||||
"github.com/netfoundry/ziti-tunnel-win/service/cziti"
|
||||
"github.com/netfoundry/ziti-tunnel-win/service/cziti/windns"
|
||||
@@ -38,6 +39,7 @@ import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -140,15 +142,20 @@ func SubMain(ops chan string, changes chan<- svc.Status) error {
|
||||
return nil
|
||||
}
|
||||
func waitForStopRequest(ops <-chan string) {
|
||||
|
||||
sig := make(chan os.Signal)
|
||||
signal.Notify(sig)
|
||||
loop:
|
||||
for {
|
||||
c := <-ops
|
||||
log.Infof("request for control received: %v", c)
|
||||
if c == "stop" {
|
||||
break loop
|
||||
} else {
|
||||
log.Debug("unexpected operation: " + c)
|
||||
select {
|
||||
case c := <-ops:
|
||||
log.Infof("request for control received: %v", c)
|
||||
if c == "stop" {
|
||||
break loop
|
||||
} else {
|
||||
log.Debug("unexpected operation: " + c)
|
||||
}
|
||||
case s := <-sig:
|
||||
log.Warnf("signal received! %v", s)
|
||||
}
|
||||
}
|
||||
log.Debugf("wait loop is exiting")
|
||||
@@ -693,6 +700,18 @@ func connectIdentity(id *dto.Identity) {
|
||||
}
|
||||
id.Active = true
|
||||
log.Infof("identity [%s] connected [%t] and set to active [%t]", id.Name, id.Connected, id.Active)
|
||||
|
||||
events.broadcast <- dto.IdentityEvent{
|
||||
ActionEvent: IDENTITY_ADDED,
|
||||
Id: dto.Identity{
|
||||
Name: id.Name,
|
||||
FingerPrint: id.FingerPrint,
|
||||
Active: id.Active,
|
||||
Config: idcfg.Config{},
|
||||
Status: "enrolled",
|
||||
Services: id.Services,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func disconnectIdentity(id *dto.Identity) error {
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
idcfg "github.com/netfoundry/ziti-sdk-golang/ziti/config"
|
||||
"github.com/netfoundry/ziti-tunnel-win/service/cziti"
|
||||
"github.com/netfoundry/ziti-tunnel-win/service/ziti-tunnel/config"
|
||||
"github.com/netfoundry/ziti-tunnel-win/service/ziti-tunnel/dto"
|
||||
@@ -198,6 +197,7 @@ func (t *RuntimeState) LoadIdentity(id *dto.Identity) {
|
||||
id.NFContext = ctx
|
||||
|
||||
id.Connected = true
|
||||
id.Active = true
|
||||
if ctx == nil {
|
||||
log.Warnf("connecting to identity with fingerprint [%s] did not error but no context was returned", id.FingerPrint)
|
||||
return
|
||||
@@ -216,18 +216,6 @@ func (t *RuntimeState) LoadIdentity(id *dto.Identity) {
|
||||
} else {
|
||||
log.Warnf("NOZITI set to true. this should be only used for debugging")
|
||||
}
|
||||
|
||||
events.broadcast <- dto.IdentityEvent{
|
||||
ActionEvent: IDENTITY_ADDED,
|
||||
Id: dto.Identity{
|
||||
Name: id.Name,
|
||||
FingerPrint: id.FingerPrint,
|
||||
Active: id.Active,
|
||||
Config: idcfg.Config{},
|
||||
Status: "enrolled",
|
||||
Services: id.Services,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func noZiti() bool {
|
||||
|
||||
Reference in New Issue
Block a user