小编dsh*_*rew的帖子

使用c套接字编程的arp请求和回复

我试图在Linux中使用c编程接收和发送arp数据包(Ubuntu)
我的程序工作正常(即运行没有任何错误),但我无法使用Wireshark跟踪数据包.

源代码:

#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/time.h>

#include <asm/types.h>

#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>

#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>

#define BUF_SIZE 42
#define DEVICE "eth0"
#define ETH_P_NULL 0x0
#define ETH_MAC_LEN ETH_ALEN
#define ETH_ARP 0x0806

int s = 0; /*Socketdescriptor*/
void* buffer = NULL;
long total_packets = 0;
long answered_packets = 0;

void sigint(int signum);

struct __attribute__((packed)) arp_header
{
    unsigned short arp_hd;
    unsigned short arp_pr;
    unsigned char …
Run Code Online (Sandbox Code Playgroud)

c sockets linux wireshark

16
推荐指数
3
解决办法
3万
查看次数

Firebase:如何检查用户是否已登录?

Android Firebase的新蜜蜂; 我正在尝试Firebase身份验证,我正在尝试检查用户是否已登录以执行此操作我正在使用此简单代码:

null != mAuth.getCurrentUser();
Run Code Online (Sandbox Code Playgroud)

而这个返回true虽然我没有登录,但我已经启用annonymous登录,我认为这可能是问题,但是当我检查 mAuth.getCurrentUser().isAnonymous()我得到false.

检查mAuth.getCurrentUser()IDE显示: 在此输入图像描述

这里有任何指示.

android firebase firebase-authentication

16
推荐指数
3
解决办法
2万
查看次数

用于文件上传的Firebase云功能

我有这个云功能,我写的上传文件到谷歌云存储:

const gcs = require('@google-cloud/storage')({keyFilename:'2fe4e3d2bfdc.json'});

var filePath = file.path + "/" + file.name;

    return bucket.upload(filePath, {
        destination: file.name
    }).catch(reason => {
            console.error(reason);
    });
Run Code Online (Sandbox Code Playgroud)

我曾经formidable解析上传的文件,我试图记录上传文件的属性,看起来很好; 它上传到临时目录'/tmp/upload_2866bbe4fdcc5beb30c06ae6c3f6b1aa/但是当我尝试将文件上传到gcs时出现此错误:

{ Error: EACCES: permission denied, stat '/tmp/upload_2866bbe4fdcc5beb30c06ae6c3f6b1aa/thumb_ttttttt.jpg'
    at Error (native)
  errno: -13,
  code: 'EACCES',
  syscall: 'stat',
  path: '/tmp/upload_2866bbe4fdcc5beb30c06ae6c3f6b1aa/thumb_ttttttt.jpg' }
Run Code Online (Sandbox Code Playgroud)

我使用这个html表单上传文件:

<!DOCTYPE html>
<html>
<body>

<form action="https://us-central1-appname.cloudfunctions.net/uploadFile" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload Image" name="submit">
</form>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript google-cloud-storage firebase google-cloud-functions

15
推荐指数
1
解决办法
1万
查看次数

Sony Xperia(E2003)的调试突然停止工作

我的环境:

操作系统:Ubuntu 14.04.3 LTS(Linux)
Android手机:索尼Xperia(E2003)安卓版4.4.4
IDE:Android Studio


在曾经为我工作的索尼手机上进行调试,它突然现在无法正常工作.在调试模式下运行时,执行不会在断点处停止..没有任何变化调试工作三星手机.

调试模式已启用,我可以从adb devices命令中查看设备.

adb devies 命令输出:
在此输入图像描述

usb调试连接状态:
在此输入图像描述

问题很奇怪我有很多索尼手机,而且现在都不能正常工作,所以我猜测问题出在我的系统上,但我的队友也遇到了同样的问题.

Logcat 正在工作,我看到来自用户互动的日志.

"调试器"选项卡显示此消息并永久挂起:

Connecting to the target VM, address: 'localhost:8601', transport: 'socket'
Run Code Online (Sandbox Code Playgroud)

更新:
我已经在这里检查了答案, 但我的设备没有sdcard所以不适合我.

我尝试通过单击ff图标手动连接到目标VM,但调试器立即断开连接.

在此输入图像描述

按照这里的步骤,我无法改变USB连接模式.我的手机上缺少所选的选项. 在此输入图像描述

debugging android sony-xperia

14
推荐指数
1
解决办法
643
查看次数

Adb emu命令有时不起作用

我正在使用此命令从命令行向我的模拟器发送SMS:

adb emu sms send 8888 Hello Android
Run Code Online (Sandbox Code Playgroud)

问题是命令总是不起作用; 没有错误消息,但SMS未传递给模拟器.

例如,我执行了9次命令,我只收到4条短信(其中5条缺失).

sms android adb android-emulator

9
推荐指数
1
解决办法
709
查看次数

如何使flex子高度包装内容

我基本上想要的是使每个子元素的高度包装其内容.

这是我的代码:

<style>

.parent{
        display: flex;
    }

.child{

    padding: 5px;
    margin: 10px;
    background: green;
    height: auto;
}   

</style>

<div class="parent">

    <div class="child">child1</div>
    <div class="child">child2</div>
    <div class="child">child3</div>
    <div class="child" style="height:50px">child1</div>

</div>
Run Code Online (Sandbox Code Playgroud)

输出:
在此输入图像描述

预期产量:
在此输入图像描述

html css css3 flexbox

8
推荐指数
1
解决办法
3247
查看次数

如何在建立战争时包含额外的文件?

我试图在garils-app/store我的战争中添加一个dir()BuildConfig.groovy.

grails.war.resources = {stagingDir,args->
    copy(file: "grails-app/store/**", toFile: "${stagingDir}/store")
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试构建war文件时,我收到此错误:


| Error WAR packaging error: Warning: Could not find file /home/codehx/git/appName/grails-app/store/** to copy.

看起来Grails并不认为它**是外卡,我有任何错误吗?或者,如果不可能,我如何递归地将storedir 的内容复制到我的war文件中.

grails

6
推荐指数
1
解决办法
1208
查看次数

Spring Boot 的 Grails 控制台是什么?

我最近开始在 Spring Boot 上花费更多的时间,并且开始感觉没有像应用程序这样的 shell(类似于 Grails 控制台),我可以使用存储库、服务等......在 spring boot 中是否存在这样的东西?

grails spring spring-boot

5
推荐指数
1
解决办法
780
查看次数

如何忽略Groovy模板引擎中缺少的参数

我有一个带有占位符的模板(例如$ {PARAM1}),程序成功解析了它们。但是,如果我只想解析传递给模板引擎的占位符,而忽略其他$ {}怎么办?当前,如果程序无法解析所有占位符,则该程序将失败。

static void main(String[] args) {

    def template = this.getClass().getResource('/MyFile.txt').text

    def parameters = [
        "PARAM1": "VALUE1",
        "PARAM2": "VALUE2"
    ]
    def templateEngine = new SimpleTemplateEngine()
    def output = templateEngine.createTemplate(template).make(parameters)
    print output
}
Run Code Online (Sandbox Code Playgroud)

档案:$ {PARAM1} $ {PARAM2} $ {PARAM3}

谢谢

groovy template-engine

5
推荐指数
1
解决办法
561
查看次数

runCommand vs aggregate方法进行聚合

要运行聚合查询,可以使用以下任一方法:

db.collectionName.aggregate(query1);
Run Code Online (Sandbox Code Playgroud)

要么

db.runCommand(query2)
Run Code Online (Sandbox Code Playgroud)

但是今天早上我注意到了一些奇怪的事情.这个:

db.runCommand(

{
   "aggregate":"collectionName",
    allowDiskUse: true,
   "pipeline":[
      {
         "$match":{
            "field":param


         }
      }

   ]
});
Run Code Online (Sandbox Code Playgroud)

失败并出错:

{
    "ok" : 0.0,
    "errmsg" : "aggregation result exceeds maximum document size (16MB)",
    "code" : 16389,
    "codeName" : "Location16389"
}
Run Code Online (Sandbox Code Playgroud)

这个:

db.collectionName.aggregate([

{
  $match: {
           field: param
   }
}

]) 
Run Code Online (Sandbox Code Playgroud)

正在工作(给出预期的聚合结果).

这怎么可能?

mongodb aggregation-framework runcommand

2
推荐指数
1
解决办法
787
查看次数

Grails如何JSONify域对象,包括其嵌套域类?

我试图在grails中做一对多的域映射.这是两个类:

class TNDetails {

String tn
String tnpk

static hasMany = [iccid: ICCID]

static mapping = {
    table 'ni_tn'
    version false
    tnpk column : 'TN_PK'
    tn column: 'TN'
    id column: 'TN_PK',name: 'tnpk'
    }

}

class ICCID {

String sim
String customer
static belongsTo = [tn: TNDetails]


static mapping = {
    table 'ni_sim'
    version false
    sim column: 'ICCID'
    customer column: 'CUSTOMER'
    tn column: 'TN_FK'
    id column: 'SIM_PK'
  }
}
Run Code Online (Sandbox Code Playgroud)

相应的查询可以写成:select TN,ICCID from ni_tn,ni_sim where ni_tn.TN_PK = ni_sim.RELATED_TN and tn_pk=1290.当我通过传递tn_pk这样获取细节时,我的控制器中是否存在: …

grails groovy grails-orm

1
推荐指数
1
解决办法
2650
查看次数