nodejs error: socket hang up

socket hang up 的可能原因有很多,大多是服务器资源不足引起。

检查 ulimit -n (所有的 port process 资源受它限制)
sudo lsof -i|wc -l
检查 memory (内存耗尽也会出错)
free -m

新方案:
使用nginx做反向代理请求nodejs可以有效的减小甚至避免这个问题

location / {
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-NginX-Proxy true;
  proxy_set_header Host $http_host;
  
  proxy_pass http://127.0.0.0:8000; // nodejs server 
  proxy_redirect off;
}

案例:

memory error
ulimit error

华为手表进入bootloader

手动进入bootloader步骤:

长按表冠不要松开,手表会重启黑屏2秒钟,随后出现华为logo,并震动一次。此时迅速短按一次表冠。
此时应该会立刻进入bootloader ,如果依然出现华为logo,请重复上述步骤。

antidebugging

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

// For debugger_ptrace. Ref: https://www.theiphonewiki.com/wiki/Bugging_Debuggers
#import <dlfcn.h>
#import <sys/types.h>

// For debugger_sysctl
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sysctl.h>
#include <stdlib.h>

// For ioctl
#include <termios.h>
#include <sys/ioctl.h>

// For task_get_exception_ports
#include <mach/task.h>
#include <mach/mach_init.h>

typedef int (*ptrace_ptr_t)(int _request, pid_t _pid, caddr_t _addr, int _data);

#if !defined(PT_DENY_ATTACH)
#define PT_DENY_ATTACH 31
#endif // !defined(PT_DENY_ATTACH)

/*!
@brief This is the basic ptrace functionality.
@link http://www.coredump.gr/articles/ios-anti-debugging-protections-part-1/
/
void debugger_ptrace()
{
void
handle = dlopen(0, RTLD_GLOBAL | RTLD_NOW);
ptrace_ptr_t ptrace_ptr = dlsym(handle, "ptrace");
ptrace_ptr(PT_DENY_ATTACH, 0, 0, 0);
dlclose(handle);
}

- 阅读剩余部分 -

How to Disable System Integrity Protection (rootless) in Mac OS X

Enable or Disable System Integrity Protection Rootless in Mac OS X

Apple has enabled a new default security oriented featured called System Integrity Protection, often called rootless, in Mac OS from versions 10.11 onward. The rootless feature is aimed at preventing Mac OS X compromise by malicious code, whether intentionally or accidentally, and essentially what SIP does is lock down specific system level locations in the file system while simultaneously preventing certain processes from attaching to system-level processes.

While the System Integrity Protection security feature is effective and the vast majority of Mac users should leave rootless enabled, some advanced Mac users may find rootless to be overly protective. Thus, if you’re in the group of advanced Mac users who do not want SIP rootless enabled on their OS X installation, we’ll show you how to turn this security feature off.

- 阅读剩余部分 -