5 Replies Latest reply on Sep 21, 2012 2:00 AM by GoodNewsJim

    Hello: How can I designate a master peer?

    GoodNewsJim Level 1



      I'm able to create a peer network and chat.

      I want to have one peer be a master peer that people login to and save/load information from.


      Without a master peer, I can still fake a master peer, but it has security vulnerabilities that could render my ap useless if someone wants to be a jerk.



        • 1. Re: Hello: How can I designate a master peer?
          Michael Thornburgh Adobe Employee

          if you're using a NetGroup posting and/or multicast, you can set a password for using those functions.  you then have two groupspecs: the groupspecWithAuthorizations, which you give to the "master peer" and which allows it to use those functions, and the groupspecWithoutAuthorizations, which you give to all non-master peers and which allows them to receive postings and/or multicasts but not send/publish.

          1 person found this helpful
          • 2. Re: Hello: How can I designate a master peer?

            But if they know the password, the game is over? There is no way to get rid of these user afterwards. This is the worst problem for this technology and second is with p2p brandwidth popup dialog.

            1 person found this helpful
            • 3. Re: Hello: How can I designate a master peer?
              GoodNewsJim Level 1

              Michael Thornburgh: Can you tell me how the code would look?

              I can't figure out how to transmit a password on the network without everyone seeing it.

              Sure you can encrypt the password, but if someone decompiles the source(ez), they can find the encryption code and then use it to decrypt the password which is sent over public P2P.


              Here is code from @tomkrcha:

              In it, I can get a chat room, where everyone can pass information between each other.

              I can not pass private information though because I can't figure out how to do direct connects via P2P.  Is there a way to do direct connect P2P?  This would be important for games where latency matters.


              Cirrus is exciting for me because it means I might not have to pay for an expensive server to run my P2P coding, and then I can run games that would require a milliondollar server for free!  I've written a P2P server/peer architecture in C/C++ for action games, but I'm having trouble finding out how Cirrus works.


              I think the easiest solution would be if Cirrus allowed you to connect to IP addresses as a direct connect P2P connection.  Then if you had a server with a static IP running someplace, peers could connect to that "master peer" directly for login details.  Is it possible to direct connect to an IP using UDP P2P? If there is, Cirrus is much more useful! 


              <?xml version="1.0" encoding="utf-8"?>

              <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"


                             xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="connect()">


                      <!-- Place non-visual elements (e.g., services, value objects) here -->





                          private const SERVER:String = "rtmfp://p2p.rtmfp.net/";

                          private const DEVKEY:String = "xed out for security reasons";


                          private var nc:NetConnection;

                          private var netGroup:NetGroup;



                          private var user:String;



                          private var connected:Boolean = false;


                          private function connect():void{

                              nc = new NetConnection();





                          private function netStatus(event:NetStatusEvent):void{




                                  case "NetConnection.Connect.Success":




                                  case "NetGroup.Connect.Success":

                                      connected = true;




                                  case "NetGroup.Posting.Notify":






                          private function setupGroup():void{

                              var groupspec:GroupSpecifier = new GroupSpecifier("Jimsgroup");

                              groupspec.serverChannelEnabled = true;

                              groupspec.postingEnabled = true;


                              trace("Groupspec: "+groupspec.groupspecWithAuthorizations());


                              netGroup = new NetGroup(nc,groupspec.groupspecWithAuthorizations());




                              user = "user"+Math.round(Math.random()*10000);



                          private var sequence:uint = 0;


                          private function sendMessage():void{


                              var message:Object = new Object();

                              message.sender = netGroup.convertPeerIDToGroupAddress(nc.nearID);

                              //message.sequence = sequence++;

                              message.user = txtUser.text;

                              message.text = txtMessage.text;






                              txtMessage.text = "";



                          private function receiveMessage(message:Object):void{

                              write(message.user+": "+message.text);



                          private function write(txt:String):void{

                              txtHistory.text += txt+"\n";






                  <s:TextArea left="10" right="10" top="10" bottom="40" id="txtHistory"/>

                  <s:TextInput x="10" id="txtUser" text="{user}" bottom="10"/>

                  <s:TextInput left="145" right="88" id="txtMessage" bottom="10" enter="sendMessage()"/>

                  <s:Button label="Send" click="sendMessage()" enabled="{connected}" bottom="10" right="10"/>



              • 4. Re: Hello: How can I designate a master peer?
                Michael Thornburgh Adobe Employee

                the idea would be that the two groupspecs (with and without authorizations) would come from, say, the web server, and only the groupspec without authorizations would be transmitted to all peers. you must treat the groupspecWithAuthorizations (which contains the password) as secret and only give it to the users you want to have it.


                one way to get the groupspecs onto the web server would be to have the user that's to be the "master peer" generate the groupspecs and send them to the web server to be distributed to the other peers.  and you can use flash.crypto.generateRandomBytes() as a source of good cryptographic pseudorandom data to become the password (after hexifying or base64-izing it or something).


                FMS has the GroupSpecifier class as well as Flash Player, and could therefore generate and distribute the groupspecs.


                there is no way to revoke an authorization in an RTMFP group.

                • 5. Re: Hello: How can I designate a master peer?
                  GoodNewsJim Level 1

                  So that isn't horrible...


                  My minor problem is giving out the password privately.

                  Since there is no way to do direct connects to peers, when you transmit the password over the RTMFP, all peers get the password.

                  Encrypting the password does not work because people can just decompile the .swf, and get the encryption key.  The people looking to hack up the software would be able to do this easily.


                  Do you suggest running a TCP/IP connection to a static server for authentication?  Or is there a way to direct connect P2P so you can do traditional P2P without being forced to RTMFP?