Is it legal?
Unlike illegal drugs, prescription medicines like modafinil are manufactured under strict conditions and rigorously tested before leaving the factory. If your doctor prescribed modafinil you would be confident that the product received from the pharmacy had been manufactured safely, stored correctly, and actually contains the right medicine. Your doctor and the pharmacist care about your personal health and are fully trained to ensure you receive the best possible medical care.
Modafinil can only be legally supplied by a pharmacist on the instruction of a doctor - to sell or supply modafinil in any other way is illegal. So anyone who is offering modafinil, no matter how reputable they appear, whether through a website or through a friend, has obtained it and is selling it illegally.
They do not care about your health or wellbeing; they care about making money. They have not checked your medical details to make sure the medicine is appropriate. The 'medicine' you are sold could be fake with no active ingredient; it could be contaminated or adulterated, or it could be degraded or unstable. You have no way of knowing what is actually in the tablets. You should think of it in the same way you would an illegal drug - an unknown chemical bought from a dodgy dealer with only profit in mind.
The Medicines and Healthcare Products Regulatory Agency (MHRA) provides advice on how to safely buy medicines over the internet using registered pharmacies trading within the law. These pharmacy websites are issued with an official 'green cross' symbol and can be found on the General Pharmaceutical Council's register of pharmacies.
But there is no way to 'safely' buy modafinil over the internet because there is no legal way of selling it - you must have a doctor's prescription.