I need a stun server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



look at this code.
 if (data->size() > 4)
 {...
 }
 else
 {      WarningLog(<< "Not enough data for stun message or framed message.  Closing connection.");
      close();
      return;
 }
 and the parameter boost::shared_ptr<DataBuffer>& data may be not a full stun packet.
  
 void 
TlsConnection::onReceiveSuccess(const asio::ip::address& address, unsigned short port, boost::shared_ptr<DataBuffer>& data)
{
   if (data->size() > 4)
   {
      /*
      std::cout << "Read " << bytesTransferred << " bytes from tls socket (" << address.to_string() << ":" << port << "): " << std::endl;
      cout << std::hex;
      for(int i = 0; i < data->size(); i++)
      {
         std::cout << (char)(*data)[i] << "(" << int((*data)[i]) << ") ";
      }
      std::cout << std::dec << std::endl;
      */
       if(((*data)[0] & 0xC0) == 0)  // Stun/Turn Messages always have bits 0 and 1 as 00 - otherwise ChannelData message
      {
         // Try to parse stun message
         StunMessage request(StunTuple(StunTuple::TLS, mSocket.lowest_layer().local_endpoint().address(), mSocket.lowest_layer().local_endpoint().port()),
                             StunTuple(StunTuple::TLS, address, port),
                             (char*)&(*data)[0], data->size());
         if(request.isValid())
         {
            StunMessage response;
            RequestHandler::ProcessResult result = mRequestHandler.processStunMessage(this, request, response);
             switch(result)
            {
            case RequestHandler::NoResponseToSend:
               // No response to send - just receive next message
               doFramedReceive();
               return;
            case RequestHandler::RespondFromAlternatePort:
            case RequestHandler::RespondFromAlternateIp:
            case RequestHandler::RespondFromAlternateIpPort:
               // These only happen for UDP server for RFC3489 backwards compatibility
               assert(false);
               break;
            case RequestHandler::RespondFromReceiving:
            default:
               break;
            }
#define RESPONSE_BUFFER_SIZE 1024
            boost::shared_ptr<DataBuffer> buffer = allocateBuffer(RESPONSE_BUFFER_SIZE);
            unsigned int responseSize;
            responseSize = response.stunEncodeMessage((char*)buffer->data(), RESPONSE_BUFFER_SIZE);
            buffer->truncate(responseSize);  // set size to real size
             doSend(response.mRemoteTuple, buffer);
         }
         else
         {
            WarningLog(<< "Received invalid StunMessage.  Dropping.");
         }
      }
      else // ChannelData message
      {
         unsigned short channelNumber;
         memcpy(&channelNumber, &(*data)[0], 2);
         channelNumber = ntohs(channelNumber);
          mRequestHandler.processTurnData(channelNumber,
                                         StunTuple(StunTuple::TLS, mSocket.lowest_layer().local_endpoint().address(), mSocket.lowest_layer().local_endpoint().port()),
                                         StunTuple(StunTuple::TLS, address, port),
                                         data);
      }
   }
   else
   {
      WarningLog(<< "Not enough data for stun message or framed message.  Closing connection.");
      close();
      return;
   }
    doFramedReceive();
}
   
  
  ------------------ Original ------------------
  From:  "twok48bit"<twok48bit@xxxxxx>;
 Date:  Fri, Nov 20, 2009 09:52 AM
 To:  "pjsip list"<pjsip at lists.pjsip.org>; 
 
 Subject:  Re: I need a stun server

  
I have no idea what your saying. It works fine as is. Why would you have a "partial" message under the context of TCP? TCP handles this where UDP does not. 

 2048
 
  On Nov 19, 2009, at 8:45 PM, 44072429 wrote:

  Hi.
 I had seen reTurn's source code.
 and i found it there was no stream integrality  check.
 it means that e.g. a tcp stun packet "STUN MESSAGE".
  when there is no delay.the server will work well.
 but when there is a delay.the server may be receive "STUN M".
 that will cause the server can not work.and response bad request error.
  
 so .i do not think reTurn can work well.
 Am I Right??????
  
  ------------------ Original ------------------
  From:  "twok48bit"<twok48bit@xxxxxx>;
 Date:  Thu, Nov 19, 2009 04:41 PM
 To:  "pjsip list"<pjsip at lists.pjsip.org>; 
 
 Subject:  Re: I need a stun server

  
xutm,  I'm not sure what your asking. Compile reTurn with your own configuration and certificates and use it. 
 

 2048
 

   On Nov 19, 2009, at 1:56 AM, xutm wrote:

 Hi twok48bit ,
    Do you have write any documents about resiprocate STUN/TURN server works with pjsip? Can you show me some if u have or give me some ideas about this ? I am working this but without any ideas. Thanks in advances.

xutm



 2009/11/19 twok48bit <twok48bit at me.com>
   

 The pjnath library implements ICE and therefore it ships with a STUN and TURN server. Also I the resiprocate STUN/TURN server works fine(it is compliant) with pjnath/pjsip.
 

 2048
  
 
  On Nov 18, 2009, at 9:00 PM, 44072429 wrote:

  hello.
 I have a stun/turn server myself.
 if you want to test icedemo.i can send it to you.
 of cource no source file.only binary app.
  
 If you find any stun/turn server that has full implement and more useful .tell me too.thanks.
   
  
  ------------------ Original ------------------
  From:  "Giant Jupiter"<giantjupiter@xxxxxxxxx>;
 Date:  Thu, Nov 19, 2009 01:09 AM
 To:  "pjsip"<pjsip at lists.pjsip.org>; 
 
 Subject:  I need a stun server

  
Hi,

To test icedemo.c, I need a STUN/TURN server. In your FAQ, it's said 

"As of version 1.4-ish, ... ... and now that there is one available,...... "

What is the "one" here? Is it ReTurn (http://www.resiprocate.org/ReTurn_Overview)? Has the compatiblity been tested?

Thanks.





      

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org






_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org



_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org





_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20091120/e5efc056/attachment-0001.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux