feat: add a mx check
This commit is contained in:
		
							parent
							
								
									b49cfbc816
								
							
						
					
					
						commit
						b12296d780
					
				| 
						 | 
					@ -62,6 +62,45 @@ const spf = (req, res) => {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const a = (req, res) => {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        const { domain } = req.query;
 | 
				
			||||||
 | 
					        console.log(domain)
 | 
				
			||||||
 | 
					        dns.resolve4(domain, (err, address) => {
 | 
				
			||||||
 | 
					            if (err) {
 | 
				
			||||||
 | 
					                console.log(err)
 | 
				
			||||||
 | 
					                return res.status(400).send("ERROR: No a record found")
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                return res.status(200).send(address)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    catch (err) {
 | 
				
			||||||
 | 
					        console.log(err)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const mx = (req, res) => {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        const { domain } = req.query;
 | 
				
			||||||
 | 
					        console.log(domain)
 | 
				
			||||||
 | 
					        dns.resolveMx(domain, (err, address) => {
 | 
				
			||||||
 | 
					            if (err) {
 | 
				
			||||||
 | 
					                console.log(err)
 | 
				
			||||||
 | 
					                return res.status(400).send("ERROR: No mx record found")
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                return res.status(200).send(address)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    catch (err) {
 | 
				
			||||||
 | 
					        console.log(err)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const parseSPF = (domain, spf, swipl, curr, callback) => {
 | 
					const parseSPF = (domain, spf, swipl, curr, callback) => {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        console.log(domain, spf, curr)
 | 
					        console.log(domain, spf, curr)
 | 
				
			||||||
| 
						 | 
					@ -263,6 +302,8 @@ const parseSPF = (domain, spf, swipl, curr, callback) => {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.get('/spf', spf)
 | 
					app.get('/spf', spf)
 | 
				
			||||||
 | 
					app.get('/a', a)
 | 
				
			||||||
 | 
					app.get('/mx', mx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.listen(PORT, (err) => {
 | 
					app.listen(PORT, (err) => {
 | 
				
			||||||
    if (err) {
 | 
					    if (err) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user