Merge branch 'issue-69' into clint

This commit is contained in:
ziti-ci
2020-07-16 13:35:46 -04:00
11 changed files with 101 additions and 49 deletions
+1 -1
View File
@@ -230,7 +230,7 @@ namespace ZitiDesktopEdge {
}
if (e.Action == "added") {
ZitiService zs = new ZitiService(e.Service.Name, e.Service.HostName, e.Service.Port, ""); // CLINT: Gimme an error
ZitiService zs = new ZitiService(e.Service);
var svc = found.Services.Find(s => s.Name == zs.Name);
if (svc == null) found.Services.Add(zs);
else Debug.WriteLine("the service named " + zs.Name + " is already accounted for on this identity.");
+1 -1
View File
@@ -44,7 +44,7 @@ namespace ZitiDesktopEdge.Models {
if (id.Services != null) {
foreach (var svc in id.Services) {
var zsvc = new ZitiService(svc.Name, svc.HostName, svc.Port, ""); // CLINT: Warning needed
var zsvc = new ZitiService(svc);
zid.Services.Add(zsvc);
}
}
+43 -6
View File
@@ -1,18 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation.Language;
using System.Text;
using System.Threading.Tasks;
namespace ZitiDesktopEdge.Models {
public class ZitiService {
public string Name { get; set; }
public string Url { get; set; }
public string Warning { get; set; }
public ZitiService(string Name, string hostname, int port, string warning) {
this.Name = Name;
this.Url = hostname + ":" + port;
this.Warning = warning;
public string AssignedIP { get; set; }
public string Host { get; set; }
public string Port { get; set; }
public bool OwnsIntercept { get; set; }
public string Url
{
get
{
if (this.OwnsIntercept)
{
return Host + ":" + Port;
} else
{
return AssignedIP + ":" + Port;
}
}
}
public string Warning
{
get
{
if (this.OwnsIntercept)
{
return "";
}
else
{
return $"Another identity is already mapped the specified hostname: {Host}.\nThis service is only available via IP";
}
}
}
public ZitiService() {
}
public ZitiService(ZitiDesktopEdge.ServiceClient.Service svc)
{
this.Name = svc.Name;
this.AssignedIP = svc.AssignedIP;
this.Host = svc.InterceptHost;
this.Port = svc.InterceptPort.ToString();
this.OwnsIntercept = svc.OwnsIntercept;
}
}
}
-2
View File
@@ -122,8 +122,6 @@ namespace ZitiDesktopEdge.ServiceClient
_extendedDebug = true;
}
}
//establish the named pipe to the service
setupPipe();
}
catch(Exception ex)
{
+5 -3
View File
@@ -126,8 +126,10 @@ namespace ZitiDesktopEdge.ServiceClient
public class Service
{
public string Name { get; set; }
public string HostName { get; set; }
public UInt16 Port { get; set; }
public string InterceptHost { get; set; }
public UInt16 InterceptPort { get; set; }
public bool OwnsIntercept { get; set; }
public string AssignedIP { get; set; }
}
public class EnrollmentFlags
@@ -173,7 +175,7 @@ namespace ZitiDesktopEdge.ServiceClient
writer.WriteLine($" Services:");
foreach (Service s in id.Services)
{
writer.WriteLine($" Name: {s.Name} HostName: {s.HostName} Port: {s.Port}");
writer.WriteLine($" Name: {s.Name} HostName: {s.InterceptHost} Port: {s.InterceptPort}");
}
writer.WriteLine("=============================================");
}
+11 -2
View File
@@ -1,18 +1,27 @@
# Release 0.0.18
* What's New
* [#70](https://github.com/openziti/desktop-edge-win/issues/70) -
* Bug fixes
* [#69](https://github.com/openziti/desktop-edge-win/issues/69) - reference counting for identities with access to the same service
# Release 0.0.17
* What's New
* [#70](https://github.com/openziti/desktop-edge-win/issues/70) - added api ApiVersion to TunnelStatusEvent
* [#71](https://github.com/openziti/desktop-edge-win/issues/71) - add .log to rolled over log files
*
* Bug fixes
* [#59](https://github.com/openziti/desktop-edge-win/issues/59) - too many services blocked service from accepting connections from the UI
* [#61](https://github.com/openziti/desktop-edge-win/issues/61) - identity shutdown needs to be on the uv loop (issue with forgetting identities)
* [#63](https://github.com/openziti/desktop-edge-win/issues/63) - when service restarts and UI reconnects clear identities and let the service repopulate the UI
* [#67](https://github.com/openziti/desktop-edge-win/issues/67) - set the MTU based on the value reported from the interface
# Release 0.0.16
- tracking lost
+25 -21
View File
@@ -57,33 +57,37 @@ type ctxService struct {
name string
}
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)
// RegisterService will return the next ip address in the configured range. If the ip address is not
// assigned to a hostname an error will also be returned indicating why.
func (dns *dnsImpl) RegisterService(dnsNameToReg string, port uint16, ctx *CZitiCtx, name string) (net.IP, error) {
log.Infof("adding DNS entry for service name %s@%s:%d", name, dnsNameToReg, port)
DnsInit(defaultCidr, defaultMaskBits)
dnsName = dnsName + "."
dnsName := dnsNameToReg + "."
key := fmt.Sprint(dnsName, ':', port)
if cs, found := dns.serviceMap[key]; found {
if cs.ctx != ctx || cs.name != name {
return nil, fmt.Errorf(
"service mapping conflict: %s:%d is already mapped for another context", dnsName, port)
}
return dns.hostnameMap[dnsName], nil
}
dns.serviceMap[key] = ctxService{
ctx: ctx,
name: name,
}
if ip, mapped := dns.hostnameMap[dnsName]; mapped {
return ip, nil
}
nextAddr := dns.cidr | atomic.AddUint32(&dns.counter, 1)
nextIp := make(net.IP, 4)
binary.BigEndian.PutUint32(nextIp, nextAddr)
dns.hostnameMap[dnsName] = nextIp
dns.ipMap[nextAddr] = dnsName
if cs, found := dns.serviceMap[key]; found {
if cs.ctx != ctx || cs.name != name {
return nextIp, fmt.Errorf(
"service mapping conflict: %s:%d is already mapped for another context", dnsNameToReg, port)
}
return nextIp, nil
} else {
dns.serviceMap[key] = ctxService{
ctx: ctx,
name: name,
}
if ip, mapped := dns.hostnameMap[dnsName]; mapped {
return ip, nil
}
dns.hostnameMap[dnsName] = nextIp
dns.ipMap[nextAddr] = dnsName
}
return nextIp, nil
}
+9 -9
View File
@@ -99,6 +99,7 @@ type Service struct {
Id string
InterceptHost string
InterceptPort uint16
AssignedIP string
}
type CZitiCtx struct {
@@ -172,13 +173,6 @@ func serviceCB(nf C.ziti_context, service *C.ziti_service, status C.int, data un
port = int(c["port"].(float64))
}
}
added := Service{
Name: name,
Id: id,
InterceptHost: host,
InterceptPort: uint16(port),
}
ctx.Services.Store(id, added)
if host != "" && port != -1 {
ip, err := DNS.RegisterService(host, uint16(port), ctx, name)
if err != nil {
@@ -189,6 +183,14 @@ func serviceCB(nf C.ziti_context, service *C.ziti_service, status C.int, data un
t.AddIntercept(id, name, ip.String(), port, unsafe.Pointer(ctx.zctx))
}
}
added := Service{
Name: name,
Id: id,
InterceptHost: host,
InterceptPort: uint16(port),
AssignedIP: ip.String(),
}
ctx.Services.Store(id, added)
ServiceChanges <- ServiceChange{
Operation: ADDED,
Service: &added,
@@ -272,7 +274,6 @@ func(c *CZitiCtx) Shutdown() {
var logFile *os.File //the current, active log file
var logLevel int //set in InitializeCLogger
var lastRollover = time.Now()
func InitializeCLogger(level int) {
logLevel = level
@@ -284,7 +285,6 @@ func InitializeCLogger(level int) {
}
func initiateRollLog() {
lastRollover = time.Now()
async := (*C.uv_async_t)(C.malloc(C.sizeof_uv_async_t))
C.uv_async_init(_impl.libuvCtx.l, async, C.uv_async_cb(C.cron_callback))
C.uv_async_send((*C.uv_async_t)(unsafe.Pointer(async)))
+1
View File
@@ -28,6 +28,7 @@ func dbg() {
events.broadcast <- dto.TunnelStatusEvent{
StatusEvent: dto.StatusEvent{Op: "status"},
Status: r,
ApiVersion: API_VERSION,
}
svcs := make([]*dto.Service, 2)
+4 -3
View File
@@ -300,7 +300,7 @@ func accept(p net.Listener, serveFunction func(net.Conn), debug string) {
func serveIpc(conn net.Conn) {
log.Debug("beginning ipc receive loop")
defer log.Warn("IPC Loop has exited")
defer log.Info("A connected IPC client has disconnected")
defer closeConn(conn) //close the connection after this function invoked as go routine exits
events.broadcast <- dto.TunnelStatusEvent{
@@ -519,7 +519,7 @@ loop:
case msg := <-consumer:
err := o.Encode(msg)
if err != nil {
log.Infof("exiting from serveEvents - %v", err)
log.Debugf("exiting from serveEvents - %v", err)
break loop
}
_ = w.Flush()
@@ -527,7 +527,7 @@ loop:
break loop
}
}
log.Debug("exiting serve events")
log.Info("a connected event client has disconnected")
}
func reportStatus(out *json.Encoder) {
@@ -828,6 +828,7 @@ func acceptServices() {
InterceptHost: c.Service.InterceptHost,
InterceptPort: c.Service.InterceptPort,
Id: c.Service.Id,
AssignedIP: c.Service.AssignedIP,
}
id.Services = append(id.Services, &svc)
+1 -1
View File
@@ -1 +1 @@
0.0.17
0.0.18