heytrav / nodepp

EPP implemented in node.js
MIT License
38 stars 16 forks source link

buffer error #7

Open chrisschaub opened 7 years ago

chrisschaub commented 7 years ago

I am running the nodepp server with a simple login / pass setup. I get a secure connection no problem, but then I get this error right after welcome screen is echoed out ...

buffer.js:680 throw new RangeError('index out of range'); ^

RangeError: index out of range at checkOffset (buffer.js:680:11) at Buffer.readUInt32BE (buffer.js:754:5) at ProtocolConnection.readStream (/home/ubuntu/dev/nodepp/lib/connection.js:89:37) at TLSSocket. (/home/ubuntu/dev/nodepp/lib/connection.js:59:22) at emitNone (events.js:67:13) at TLSSocket.emit (events.js:166:7) at emitReadable_ (_stream_readable.js:419:10) at emitReadable (_stream_readable.js:413:7) at readableAddChunk (_stream_readable.js:164:13) at TLSSocket.Readable.push (_stream_readable.js:111:10)

chrisschaub commented 7 years ago

Get this as it is starting up ...

debug: Calling epp command. info: Establishing connection.. info: Established a secure connection. debug: Read event debug: endian length: 500 debug: current buffer length 4 debug: Read event debug: endian length: 500 debug: current buffer length 5 debug: Read event debug: endian length: 500 debug: current buffer length 500 info: Received: <login xml ....>

heytrav commented 7 years ago

Seems like it's calling readStream right after printing out the greeting and the buffer is empty. I don't have any means to debug this (no registry accounts), but it might be worthwhile to log out what is in the buffer just before it tries to read the totalLength.

chrisschaub commented 7 years ago

info: Established a secure connection. debug: Read event <Buffer 00 00 01 f4> debug: endian length: 500 debug: current buffer length 4 debug: Read event <Buffer 00 00 01 f4 3c> debug: endian length: 500 debug: current buffer length 5 debug: Read event

<Buffer 00 00 01 f4 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 22 31 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 55 54 46 2d 38 22 3f 3e 0a 3c 65 70 70 20 78 6d ... >

debug: endian length: 500 debug: current buffer length 500 info: Received: info: <?xml version="1.0" encoding="utf-8"?> ..... xml here info: Finished writing to server. debug: Read event

<Buffer 00>

buffer.js:680 throw new RangeError('index out of range'); ^

RangeError: index out of range at checkOffset (buffer.js:680:11) at Buffer.readUInt32BE (buffer.js:754:5) at ProtocolConnection.readStream (/home/ubuntu/dev/nodepp/lib/connection.js:88:37) at TLSSocket. (/home/ubuntu/dev/nodepp/lib/connection.js:59:22) at emitNone (events.js:67:13) at TLSSocket.emit (events.js:166:7) at emitReadable_ (_stream_readable.js:419:10) at emitReadable (_stream_readable.js:413:7) at readableAddChunk (_stream_readable.js:164:13) at TLSSocket.Readable.push (_stream_readable.js:111:10)

chrisschaub commented 7 years ago

Changing calls from

readUInt32BE

to

readUIntBE

seems to have fixed it. For nodejs greater than .12.

From here: http://stackoverflow.com/questions/30911185/javascript-reading-3-bytes-buffer-as-an-integer

readUIntBE allows a variable number of bytes.

chrisschaub commented 7 years ago

I'm past that issue, I think. Now all of my requests give ...

{"error":"Not logged in."}

Assuming this means my creds are failing?

heytrav commented 7 years ago

You'd have to log out the xml output to make sure how it's responding to the login. If they are failing you should be getting an error message in response to your login request.

heytrav commented 7 years ago

And would you mind submitting a patch for the fix?

chrisschaub commented 7 years ago

Yes, I'll submit a patch. It seems like our server needs all requests wrapped in epp tag ?

<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
 <response>
  <result code="2001">
   <msg lang="en-US">Command syntax error</msg>
   <value>
    <text>[Error] :2:45: cvc-elt.1: Cannot find the declaration of element 'epp'.</text>
   </value>
  </result>
 </response>
</epp>
heytrav commented 7 years ago

All the requests should be enclosed in <epp> by default. What does the namespaces part of your config contain?

chrisschaub commented 7 years ago

Yeah, that was up. Making pull reqeust for BigEndian stuff.

On Sat, Nov 5, 2016 at 12:17 PM, William Travis Holton < notifications@github.com> wrote:

All the requests should be enclosed in by default. What does the namespaces part of your config contain?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/heytrav/nodepp/issues/7#issuecomment-258626464, or mute the thread https://github.com/notifications/unsubscribe-auth/ADKssFe9lr5triP4zWlzZBFOEE7WDLuZks5q7LpBgaJpZM4KpuUW .

Christopher Schaub http://chris.schaub.com

chrisschaub commented 7 years ago

https://github.com/heytrav/nodepp/pull/8

chrisschaub commented 7 years ago

One last question. I get back a successful login now on the console. Should I be able to post to port 3000 a command like

{"domain": "something.ga"}

when I do, I get a not logged in error, even though I can see the server running port 3000 got logged in. Do I need to use the nodepp-req library and rabbitmq to test this? Or should posting to a port as json be enough to test? Thanks for your help!

heytrav commented 7 years ago

I assume you mean posting that data structure to something like:

http://localhost:3000/command/<registry in config>/checkDomain

or

http://localhost:3000/command/<registry in config>/infoDomain

Then yes, that should work. The rabbitmq setup is just an alternative way to use the service, but it was intended to work via http requests as well.

chrisschaub commented 7 years ago

Ok, making progress. I needed to add a try / catch to handle cases where the buffer is empty during phases of the connection. But I am still getting this error:

The matching wildcard is strict, but no declaration can be found for element 'domain:check'."

Assuming the issues is with namespaces. For domain they are ...

"domain": { "xmlns": "urn:ietf:params:xml:ns:domain-1.0", "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation": "urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd" },

That's what I was given. Any ideas what else could be causing this? Thanks!

heytrav commented 7 years ago

What do you have in the services section of your config? This tells the EPP server which types of entity you want to manipulate. Some registries support custom objects and some don't support contacts for example. An example of what I have is

            "services": ["domain", "contact"],

and for namespaces:

            "namespaces":{
                "epp": {
                    "xmlns": "urn:ietf:params:xml:ns:epp-1.0"
                },
                "domain": {
                    "xmlns": "urn:ietf:params:xml:ns:domain-1.0"
                },
                "contact": {
                    "xmlns": "urn:ietf:params:xml:ns:contact-1.0"
                },
                "DNSSEC": {
                    "xmlns": "urn:ietf:params:xml:ns:secDNS-1.1"
                }
            }

It's not really necessary to put xmlns:xsi or xsi:schemaLocation in there.