~ztefn/haguichi/1.4

« back to all changes in this revision

Viewing changes to src/hamachi.vala

  • Committer: Stephen Brandt
  • Date: 2021-10-03 13:51:14 UTC
  • Revision ID: git-v1:6660e49358f9422667fdab6c46ffc7fa2f209687
Standardize empty IP address return values

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    
24
24
    public static void init ()
25
25
    {
26
 
        ip_version   = "IPv4";
 
26
        ip_version   = "";
27
27
        demo_account = "-";
28
28
        
29
29
        get_info();
260
260
            
261
261
            ipv4 = mi.fetch_named ("ipv4");
262
262
            ipv6 = mi.fetch_named ("ipv6");
 
263
            
 
264
            Debug.log (Debug.domain.HAMACHI, "Hamachi.get_address", "IPv4: " + ipv4);
 
265
            Debug.log (Debug.domain.HAMACHI, "Hamachi.get_address", "IPv6: " + ipv6);
263
266
        }
264
267
        catch (RegexError e)
265
268
        {
266
269
            Debug.log (Debug.domain.ERROR, "Hamachi.get_address", e.message);
267
270
        }
268
271
        
269
 
        if ((ipv4 != "") &&
 
272
        if (ipv4 == "")
 
273
        {
 
274
            ipv4 = null;
 
275
        }
 
276
        
 
277
        if (ipv6 == "")
 
278
        {
 
279
            ipv6 = null;
 
280
        }
 
281
        
 
282
        if ((ipv4 != null) &&
270
283
            (ipv6 != null))
271
284
        {
272
285
            ip_version = "Both";
273
286
        }
274
 
        else if (ipv4 != "")
 
287
        else if (ipv4 != null)
275
288
        {
276
289
            ip_version = "IPv4";
277
290
        }
280
293
            ip_version = "IPv6";
281
294
        }
282
295
        
283
 
        Debug.log (Debug.domain.HAMACHI, "Hamachi.get_address", "IPv4: " + ipv4);
284
 
        Debug.log (Debug.domain.HAMACHI, "Hamachi.get_address", "IPv6: " + ipv6);
 
296
        Debug.log (Debug.domain.HAMACHI, "Hamachi.get_address", "IP version: " + ip_version);
285
297
        
286
298
        return new string[] {ipv4, ipv6};
287
299
    }