@@ -204,7 +204,9 @@ Tox.prototype.inspect = function () {
204
204
Object . keys ( this ) . forEach ( function ( k ) {
205
205
obj [ k ] = this [ k ] ;
206
206
// Hacky fix for StringSlice assert error:
207
- // void node::Buffer::StringSlice(const v8::FunctionCallbackInfo<v8::Value>&) [with node::encoding encoding = (node::encoding)5u]: Assertion `obj_data != __null' failed.
207
+ // void node::Buffer::StringSlice(const
208
+ // v8::FunctionCallbackInfo<v8::Value>&) [with node::encoding encoding =
209
+ // (node::encoding)5u]: Assertion `obj_data != __null' failed.
208
210
if ( k === "_options" ) {
209
211
// linting is weird and wants us to specifically `.toString()` this
210
212
obj [ k . toString ( ) ] = "[ToxOptions]" ;
@@ -2346,7 +2348,8 @@ Tox.prototype.getSecretKeyHexSync = function () {
2346
2348
/**
2347
2349
* Check if this Tox instance has a handle associated with it.
2348
2350
* @private
2349
- * @param {Tox~errorCallback } callback - Callback to pass Error object to if no handle
2351
+ * @param {Tox~errorCallback } callback - Callback to pass Error object to if no
2352
+ * handle
2350
2353
* @return {Boolean } true if has handle (no error), false if no handle (error)
2351
2354
*/
2352
2355
Tox . prototype . _checkHandle = function ( callback ) {
@@ -2516,20 +2519,22 @@ Tox.prototype._fixFileControl = function (control) {
2516
2519
} ;
2517
2520
2518
2521
/**
2519
- * Fix a send lossless packet value. Adds magic byte(160) to the first byte of data
2522
+ * Fix a send lossless packet value. Adds magic byte(160) to the first byte of
2523
+ * data
2520
2524
* @private
2521
2525
* @param {Buffer } data
2522
2526
* @return {Buffer } new data
2523
2527
*/
2524
2528
Tox . prototype . _fixSendLosslessPacket = function ( data ) {
2525
- //160: magic byte
2529
+ // 160: magic byte
2526
2530
return Buffer . concat ( [ Buffer . from ( [ 160 ] ) , data ] ) ;
2527
2531
} ;
2528
2532
2529
2533
/**
2530
2534
* Fix a lossless/lossy packet buffer by prepending an id byte.
2531
2535
* @private
2532
- * @param {Number } id - Byte to prepend, according to tox.h it should be in the range
2536
+ * @param {Number } id - Byte to prepend, according to tox.h it should be in the
2537
+ * range
2533
2538
* [160, 191] if lossless and [200, 254] if lossy.
2534
2539
* @param {Buffer } data - Data buffer to prepend to
2535
2540
* @return {Buffer } new data
@@ -2613,6 +2618,9 @@ Tox.prototype._setProxyToToxOptions = function (opts, options) {
2613
2618
// Store in "this' so it isn"t GC-d?
2614
2619
this . _proxyAddress = Buffer . from ( proxy . address + "\0" ) ;
2615
2620
options . proxy_address = this . _proxyAddress ;
2621
+ // TODO(iphydf): Weird hack here to make sure getOptions works.
2622
+ // Remove this and see tests fail.
2623
+ ref . reinterpretUntilZeros ( this . _proxyAddress , ref . types . char . size ) ;
2616
2624
}
2617
2625
2618
2626
// Set port
@@ -2624,7 +2632,8 @@ Tox.prototype._setProxyToToxOptions = function (opts, options) {
2624
2632
} ;
2625
2633
2626
2634
/**
2627
- * Store an ffi.Callback. This is to prevent an annoying ffi garbage collection bug.
2635
+ * Store an ffi.Callback. This is to prevent an annoying ffi garbage collection
2636
+ * bug.
2628
2637
* @private
2629
2638
* @param {Object } key - Key
2630
2639
* @param {ffi.Callback } callback - Callback
@@ -2652,7 +2661,8 @@ Tox.prototype._toFFICallback = function (ffiFunc, callback) {
2652
2661
/////////////////////
2653
2662
2654
2663
/**
2655
- * Used in: Tox#bootstrap(), Tox#bootstrapSync(), Tox#addTCPRelay(), Tox#addTCPRelaySync().
2664
+ * Used in: Tox#bootstrap(), Tox#bootstrapSync(), Tox#addTCPRelay(),
2665
+ * Tox#addTCPRelaySync().
2656
2666
* @private
2657
2667
*/
2658
2668
Tox . prototype . _performBootstrap = function ( opts ) {
@@ -3274,8 +3284,8 @@ Tox.prototype._initFileRecvChunkCb = function () {
3274
3284
cb : FileRecvChunkCallback ,
3275
3285
name : "FileRecvChunkCallback" ,
3276
3286
wrapper : function ( handle , friend , file , position , data , size , userdata ) {
3277
- // Apparently data can sometimes be a NULL pointer, set data to undefined if so
3278
- // This should only happen on final chunk?
3287
+ // Apparently data can sometimes be a NULL pointer, set data to undefined
3288
+ // if so This should only happen on final chunk?
3279
3289
if ( ref . address ( data ) !== 0 ) {
3280
3290
data = Buffer . from ( ref . reinterpret ( data , size ) ) ; // Copy to another Buffer
3281
3291
} else {
@@ -3297,12 +3307,13 @@ Tox.prototype._initFriendLosslessPacketCb = function () {
3297
3307
cb : FriendLosslessPacketCallback ,
3298
3308
name : "FriendLosslessPacketCallback" ,
3299
3309
wrapper : function ( handle , friend , data , length , userdata ) {
3300
- //if(ref.address(data) !== 0) {
3301
- // //first byte is magic byte(160) so ignore it
3302
- // data = Buffer.from(ref.reinterpret(data, (length - 1), 1)); // Copy to another Buffer
3303
- //} else {
3304
- // data = undefined;
3305
- //}
3310
+ // if (ref.address(data) !== 0) {
3311
+ // // first byte is magic byte(160) so ignore it
3312
+ // // Copy to another Buffer
3313
+ // data = Buffer.from(ref.reinterpret(data, (length - 1), 1));
3314
+ // } else {
3315
+ // data = undefined;
3316
+ // }
3306
3317
if ( ref . address ( data ) === 0 ) {
3307
3318
throw new Error ( "NULL data packet" ) ;
3308
3319
}
0 commit comments