2015-02-01 04:26:47 -05:00
|
|
|
//
|
|
|
|
|
// ServerInfoResponse.m
|
2015-05-12 21:48:30 -04:00
|
|
|
// Moonlight
|
2015-02-01 04:26:47 -05:00
|
|
|
//
|
|
|
|
|
// Created by Diego Waxemberg on 2/1/15.
|
2015-05-12 21:48:30 -04:00
|
|
|
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
|
2015-02-01 04:26:47 -05:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "ServerInfoResponse.h"
|
|
|
|
|
#import <libxml2/libxml/xmlreader.h>
|
|
|
|
|
|
|
|
|
|
@implementation ServerInfoResponse
|
|
|
|
|
@synthesize data, statusCode, statusMessage;
|
|
|
|
|
|
|
|
|
|
- (void) populateWithData:(NSData *)xml {
|
|
|
|
|
self.data = xml;
|
|
|
|
|
[super parseData];
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-01 20:31:24 -08:00
|
|
|
- (void) populateHost:(TemporaryHost*)host {
|
2015-04-05 20:30:13 -07:00
|
|
|
host.name = [[self getStringTag:TAG_HOSTNAME] trim];
|
|
|
|
|
host.uuid = [[self getStringTag:TAG_UNIQUE_ID] trim];
|
|
|
|
|
host.mac = [[self getStringTag:TAG_MAC_ADDRESS] trim];
|
2016-10-21 11:41:42 -07:00
|
|
|
host.currentGame = [[self getStringTag:TAG_CURRENT_GAME] trim];
|
|
|
|
|
|
2019-07-14 22:55:41 -07:00
|
|
|
// We might get an IPv4 loopback address if we're using GS IPv6 Forwarder
|
|
|
|
|
NSString *lanAddr = [[self getStringTag:TAG_LOCAL_IP] trim];
|
|
|
|
|
if (![lanAddr hasPrefix:@"127."]) {
|
|
|
|
|
host.localAddress = lanAddr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-26 20:28:59 -07:00
|
|
|
// Modern GFE versions don't actually give us a WAN address anymore
|
|
|
|
|
// so we leave the one that we populated from mDNS discovery via STUN.
|
|
|
|
|
NSString *wanAddr = [[self getStringTag:TAG_EXTERNAL_IP] trim];
|
|
|
|
|
if (wanAddr) {
|
|
|
|
|
host.externalAddress = wanAddr;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-21 11:41:42 -07:00
|
|
|
NSString *state = [[self getStringTag:TAG_STATE] trim];
|
2017-10-16 23:59:00 -07:00
|
|
|
if (![state hasSuffix:@"_SERVER_BUSY"]) {
|
2016-10-21 11:41:42 -07:00
|
|
|
// GFE 2.8 started keeping currentgame set to the last game played. As a result, it no longer
|
|
|
|
|
// has the semantics that its name would indicate. To contain the effects of this change as much
|
|
|
|
|
// as possible, we'll force the current game to zero if the server isn't in a streaming session.
|
|
|
|
|
host.currentGame = @"0";
|
|
|
|
|
}
|
2015-02-01 04:26:47 -05:00
|
|
|
|
2015-02-01 18:33:36 -05:00
|
|
|
NSInteger pairStatus;
|
|
|
|
|
if ([self getIntTag:TAG_PAIR_STATUS value:&pairStatus]) {
|
|
|
|
|
host.pairState = pairStatus ? PairStatePaired : PairStateUnpaired;
|
|
|
|
|
} else {
|
|
|
|
|
host.pairState = PairStateUnknown;
|
2015-02-01 04:26:47 -05:00
|
|
|
}
|
2018-06-02 13:10:10 -07:00
|
|
|
|
|
|
|
|
NSString *serverCodecModeString = [self getStringTag:@"ServerCodecModeSupport"];
|
|
|
|
|
if (serverCodecModeString != nil) {
|
|
|
|
|
host.serverCodecModeSupport = [[serverCodecModeString trim] intValue];
|
|
|
|
|
}
|
2015-02-01 04:26:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|