@@ -136,7 +136,7 @@ def connect(self, retry=0, delay=0):
136
136
return False
137
137
138
138
if isinstance (self .connection , WebsocketConnection ):
139
- self .cm_servers .bootstrap_from_webapi_websocket ( )
139
+ self .cm_servers .bootstrap_from_webapi ( cmtype = 'websockets' )
140
140
elif isinstance (self .connection , TCPConnection ):
141
141
if not self .cm_servers .bootstrap_from_webapi ():
142
142
self .cm_servers .bootstrap_from_dns ()
@@ -484,26 +484,33 @@ def bootstrap_from_dns(self):
484
484
self ._LOG .error ("DNS boostrap: cm0.steampowered.com resolved no A records" )
485
485
return False
486
486
487
- def bootstrap_from_webapi (self , cell_id = 0 ):
487
+ def bootstrap_from_webapi (self , cell_id = 0 , cmtype = 'netfilter' ):
488
488
"""
489
489
Fetches CM server list from WebAPI and replaces the current one
490
490
491
491
:param cellid: cell id (0 = global)
492
492
:type cellid: :class:`int`
493
+ :param cmtype: CM type filter
494
+ :type cellid: :class:`str`
493
495
:return: booststrap success
494
496
:rtype: :class:`bool`
495
497
"""
496
- self ._LOG .debug ("Attempting bootstrap via WebAPI" )
498
+ self ._LOG .debug ("Attempting bootstrap via WebAPI for %s" % cmtype )
497
499
498
500
from steam import webapi
499
501
try :
500
- resp = webapi .get ('ISteamDirectory' , 'GetCMList' , 1 , params = {'cellid' : cell_id ,
501
- 'http_timeout' : 3 })
502
+ resp = webapi .get ('ISteamDirectory' , 'GetCMListForConnect' , 1 ,
503
+ params = {
504
+ 'cellid' : cell_id ,
505
+ 'cmtype' : cmtype ,
506
+ 'http_timeout' : 3
507
+ }
508
+ )
502
509
except Exception as exp :
503
510
self ._LOG .error ("WebAPI boostrap failed: %s" % str (exp ))
504
511
return False
505
512
506
- result = EResult (resp ['response' ]['result ' ])
513
+ result = EResult (resp ['response' ]['success ' ])
507
514
508
515
if result != EResult .OK :
509
516
self ._LOG .error ("GetCMList failed with %s" % repr (result ))
@@ -512,41 +519,12 @@ def bootstrap_from_webapi(self, cell_id=0):
512
519
serverlist = resp ['response' ]['serverlist' ]
513
520
self ._LOG .debug ("Received %d servers from WebAPI" % len (serverlist ))
514
521
515
- def str_to_tuple (serveraddr ):
516
- ip , port = serveraddr .split (':' )
517
- return str (ip ), int (port )
518
-
519
- self .clear ()
520
- self .cell_id = cell_id
521
- self .merge_list (map (str_to_tuple , serverlist ))
522
-
523
- return True
524
-
525
- def bootstrap_from_webapi_websocket (self ):
526
- """
527
- Fetches CM server list from WebAPI and replaces the current one
528
-
529
- :return: booststrap success
530
- :rtype: :class:`bool`
531
- """
532
- self ._LOG .debug ("Attempting bootstrap via WebAPI for websocket" )
533
-
534
- from steam import webapi
535
- try :
536
- resp = webapi .get ('ISteamDirectory' , 'GetCMListForConnect' , 1 , params = {'cmtype' : 'websockets' ,
537
- 'http_timeout' : 3 })
538
- except Exception as exp :
539
- self ._LOG .error ("WebAPI boostrap failed: %s" % str (exp ))
540
- return False
541
-
542
- serverlist = resp ['response' ]['serverlist' ]
543
- self ._LOG .debug ("Received %d servers from WebAPI" % len (serverlist ))
544
-
545
522
def str_to_tuple (serverinfo ):
546
523
ip , port = serverinfo ['endpoint' ].split (':' )
547
524
return str (ip ), int (port )
548
525
549
526
self .clear ()
527
+ self .cell_id = cell_id
550
528
self .merge_list (map (str_to_tuple , serverlist ))
551
529
552
530
return True
0 commit comments